Search
 
SCRIPT & CODE EXAMPLE
 

SQL

inner join just one row

SELECT  a.*, c.*
FROM users a 
    INNER JOIN payments c
        ON a.id = c.user_ID
    INNER JOIN
    (
        SELECT user_ID, MAX(date) maxDate
        FROM payments
        GROUP BY user_ID
    ) b ON c.user_ID = b.user_ID AND
            c.date = b.maxDate
WHERE a.package = 1
Comment

PREVIOUS NEXT
Code Example
Sql :: truncate left characters mysql 
Sql :: sql random decimal 
Sql :: sql server loop over query 
Sql :: mysql substract count and distinct count 
Sql :: mysql int range 
Sql :: sql column values comma separated 
Sql :: update select 
Sql :: date_add mysql 
Sql :: postgres add superuser to database 
Sql :: show tables in schema oracle 
Sql :: woocommerce mysql price table 
Sql :: clear screen command in psql 
Sql :: sqlite version check 
Sql :: adding a check statement in sql 
Sql :: what is initial catalog in sql connection string 
Sql :: strict in postgres SQL 
Sql :: postgresql array last element 
Sql :: UPDATE if else mysql 
Sql :: HOW TO FIND MEDIAN IN SQL FOR BOTH IDD AND EVEN 
Sql :: is there any command to change postgres password 
Sql :: best sql course 
Sql :: mysql db size 
Sql :: mysql incrementation 
Sql :: oracle db get table sizes 
Sql :: random record using order by rand() mysql 
Sql :: show columns in sql 
Sql :: sql in sublime 
Sql :: create table sqlite 
Sql :: flask sqlalchemy default value 
Sql :: delete top N rows in sql 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =