/* select row_number() over (PARTITION BY OwnerUserId ord...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans

Q&A for music historians, critics, and fans

--select top 1 * from posttypes;
/*
select row_number() over
(PARTITION BY OwnerUserId order by posts.creationDate) as us from Posts p
    join users u on u.id = p.OwnerUserId and p.PostTypeId = 1
    where u.location like '%Russia%' and year(p.creationDate) = 2016 and p.title like '%SQL%' 
    group by u.id
*/
/*
select topp.* from (select * from posts p
    join users u on u.id = p.OwnerUserId and p.PostTypeId = 1
    where u.location like '%Russia%'  and 
          year(p.creationDate) = 2016 and
          p.title like '%SQL%' 
    group by p.OwnerUserId) as t1, 
    lateral (select top 1 * from posts where t1.id = posts.id order by creationDate) topp
*/


select u.id, p.creationDate from users u
    join posts p on u.id = p.OwnerUserId and p.PostTypeId = 1
    where u.location like '%Russia%'  and 
          year(p.creationDate) = 2016 and
          p.title like '%SQL%' 
    group by u.id, p.creationDate

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results