Jump to content

Sort and Group


bubbadawg

Recommended Posts

I have a recordset that returns real estate data. I need to sort and group the data on two fields property_id and sold (boolean).  So I need to have all the properties that are available (not sold) listed by property_id (desc) first and then the remaining (sold) properties listed by property_id (desc).

 

Thanks for the assistance.

Link to comment
https://forums.phpfreaks.com/topic/210868-sort-and-group/
Share on other sites

Hi

 

Grouping (ie, using GROUP BY) is used when you want to perform a function on several lines and return a combined result. For example if you had a list of cars and their tops speeds and you wanted to know the average speed for each make you would use something like:-

 

SELECT CarMake, AVG(TopSpeed)

FROM CarTable

GROUP BY CarMake

 

I don't think this is what you want, hence if you had searched for GROUP BY you would likely have got confused.

 

For you query

 

SELECT property_id, sold

FROM PropertyTable

ORDER BY sold ASC, property_id DESC

 

All the best

 

Keith

Link to comment
https://forums.phpfreaks.com/topic/210868-sort-and-group/#findComment-1099910
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.