|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here! |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Let me start with a simplified example:
I have a database with fields "size", "color" and "sort_order_by_size" short example of what the table might look like: Size, Color, sort_order_by_size S, Grey, 1 S, Blue, 2 S, Yellow, 3 M, Grey, 4 M, Yellow, 5 What I want to do is grab all "distinct" sizes and sort according to the sort_order_by_size field. I want my recordset to look like: Size, sort_order_by_size S, 1 M, 4 How do I write a query to get this result? If I do: "Select distinct size from table", I do not get my sorting. If I do: "Select distinct size, sort_order_by_size from table order by sort_order_by_size" the entire table is returned, since each value of sort_order_by_size is unique. Any one have any suggestions? |
|
|||
|
Hello,
You did not explain why you want Size, sort_order_by_size S, 1 M, 4 and not e.g. Size, sort_order_by_size S, 3 M, 5 Nevertheless, what could work is this: SELECT size, min(sort_order_by_size) FROM table GROUP BY size ORDER BY min(sort_order_by_size) best regards Sam
__________________
Software-Pointers.com - Directory of Software Development Sites - Free submission. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |