Please for efficient query
- by user278618
I want to have efficient query to get some rows from my table.
Here is I think the best presentation of my table.
-Somedate is not duplicated - it is date of modifiedon
-a,b,c are parent ids, let say countryCode
-1,2,3,4 are subparent, let say citycode
-guids are id of rows
-true, false are values of rows - one can name this column - freshAir
a 1 GUID somedate true
a 1 GUID somedate true
a 2 GUID somedate false
a 2 GUID somedate false
b 3 GUID somedate false
b 3 GUID somedate false
b 3 GUID somedate false
b 4 GUID somedate false
c 5 GUID somedate true
c 6 GUID somedate true
c 6 GUID somedate false
c 6 GUID somedate false
c 7 GUID somedate false
I want the most recent rows MAX(modifiedon) grouped by countrycode and citycode and in this groups I need elements which have another values (true, false).
And in result I want:
a 1 GUID somedate true
a 2 GUID somedate false
c 5 GUID somedate true
c 6 GUID somedate false
c 7 GUID somedate false
Look that in result I don't want to have records with "b", because all rows have the same value (false).
Best regards