Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql left join distinct on

Select Distinct On (u.username, u.email)
     u.username
    ,u.email
    ,l.browser
    ,l.login_time
From users u
Join logins l On l.username = u.username
Order By u.username, u.email, login_time Desc
 
                                        ^
Comment

PREVIOUS NEXT
Code Example
Sql :: ubuntu reset mysql root password 
Sql :: trigger in postgresql to change incoming entry 
Sql :: list all the tables in sql 
Sql :: mysql current date 
Sql :: oracle all tables 
Sql :: SQL date part only of datetime 
Sql :: mysql backup query 
Sql :: sqlite create table if not exists 
Sql :: sql truncate statement 
Sql :: update single sql column 
Sql :: where date = max(date) in sql 
Sql :: postgres populate table from another table 
Sql :: float precision in psql 
Sql :: how to select first row of database sql 
Sql :: Write a query to create an empty table from an existing table? 
Sql :: copy postgres table from one schema into another 
Sql :: SQL Server - Count number of times a specific character appears in a string 
Sql :: count mysql 
Sql :: postgresql get difference between two dates 
Sql :: sqlite data types 
Sql :: mariadb add foreign key 
Sql :: DROP TABLes regardless of constraints 
Sql :: sql extract numbers from string 
Sql :: how to change a collumn name in sql 
Sql :: select last row mysql 
Sql :: sql select where more than one record exists 
Sql :: mysql to get column name in database 
Sql :: mysql list tables by size 
Sql :: mysql union 
Sql :: ValueError: A string literal cannot contain NUL (0x00) characters. 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =