Search
 
SCRIPT & CODE EXAMPLE
 

SQL

left join with only first record

SELECT t1.*, t2.*
FROM Table1 AS t1 LEFT JOIN (
    SELECT *, ROW_NUMBER() OVER(PARTITION BY FK_Table1 ORDER BY [Date] DESC) AS RowNo
    FROM Table2  
) AS t2 ON t1.ID = t2.FK_Table1 AND t2.RowNo = 1
Comment

PREVIOUS NEXT
Code Example
Sql :: postgresql get current user name 
Sql :: add new column to the table mysql 
Sql :: change default maximum runtime mariadb from phpmyadmin 
Sql :: postgresql random number 
Sql :: postgresql show current database 
Sql :: sql remove first character from string 
Sql :: encoding UTF8 has no equivalent in encoding WIN1252 
Sql :: create procedure with encryption 
Sql :: mysql between start date and end date 
Sql :: oracle session date format 
Sql :: edate dax 
Sql :: oracle sql truncate table 
Sql :: my sql version 
Sql :: start mysql linux terminal 
Sql :: oracle list dates between 
Sql :: uninstall mysql server ubuntu 
Sql :: insert random numbers in columns postgress 
Sql :: select sql in descending order 
Sql :: sql get number of days between two dates 
Sql :: add postgresql to path 
Sql :: sql server drop table if exists 
Sql :: mysql shell ERROR: Not connected. 
Sql :: postgres date difference seconds 
Sql :: mysql query unique column 
Sql :: create table sql 
Sql :: reset identity column values in sql server 
Sql :: postgresql insert select 
Sql :: sql rename column 
Sql :: mysql user change password 
Sql :: how to create table in sql 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =