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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.