I have a Single table with
City date type vlCC vlVV key
London 24-01-2014 CC blue key1
London 25-01-2014 VV yellow key4
London 24-01-2014 VV green key2
Lisbon 24-01-2014 CC green key5
Lisbon 24-01-2014 VV red key6
London 25-01-2014 CC black key3
My first approach was a inner join but hanged here.
SELECT distinct p.city, p.date, p.type FROM Cities AS P INNER JOIN Cities AS P2
ON P.City = P2.City AND P.Date = P2.Date AND P.type <> P2.type and P.Date > GETDATE() order by p.city, p.date, p.type
My wanted output is
London 24-01-2014 blue green key1 key2
Lisbon 24-01-2014 green red key5 key6
London 25-01-2014 black yellow key3 key4
(ordered by p.city, p.date, p.type)
It means I want to "merge" the rows by city and date and order it like that (city,date )
Thanks