bubbadawg Posted August 16, 2010 Share Posted August 16, 2010 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 More sharing options...
kickstart Posted August 16, 2010 Share Posted August 16, 2010 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 More sharing options...
bubbadawg Posted August 16, 2010 Author Share Posted August 16, 2010 Hi, Thanks for your assistance. I think that will work. Link to comment https://forums.phpfreaks.com/topic/210868-sort-and-group/#findComment-1099925 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.