Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting in a group by SQL statement 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hello,<br><br>&nbsp;can anyone tell me how I can sort the return values from an SQL query based on columns which are not included in the group by clause?<br><br>eg. select max(sales) from customers group by country order by name; (this statement gives me an error saying that the name column is not a group by expression)<br><br><br>Kean Fui<br><A HREF="mailto:lookf@novasprint.com">lookf@novasprint.com</A>
 
This is usually a bit faster than using an aggregate function.<br>SELECT *<br>FROM Customers AS C0<br>WHERE NOT EXISTS (SELECT *<br> FROM Customers AS C1<br> WHERE C0.country = C1.country<br> AND C0.sales &lt; C1.sales)<br>ORDER BY C0.name<br> <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top