-
grouping and ordering from a select function
Hi, I am using MS SQL 7 on windows 2000 platform.
I have two fields getting pulled from a table and I want the results to be returned in order by price from lowest price to highest price but grouped by identification number
e.g. 1234, 2234 and 3333 are the identification numbers and the column on the left is the price
price identification number
--- -----
50 1234
60 1234
70 1234
80 1234
60 2234
70 2234
90 2234
100 2234
90 3333
120 3333
130 3333
140 3333
The main order is by price but I want the identification numbers to stay grouped as well.
Thanks alot for any help
Regards
Mark
-
grouping and ordering from a select function (reply)
Hi,
Try something like this
select price, identification_number
from table_name
order by identification_number,price
Martin
------------
Mark Jensen at 11/15/00 11:22:34 AM
Hi, I am using MS SQL 7 on windows 2000 platform.
I have two fields getting pulled from a table and I want the results to be returned in order by price from lowest price to highest price but grouped by identification number
e.g. 1234, 2234 and 3333 are the identification numbers and the column on the left is the price
price identification number
--- -----
50 1234
60 1234
70 1234
80 1234
60 2234
70 2234
90 2234
100 2234
90 3333
120 3333
130 3333
140 3333
The main order is by price but I want the identification numbers to stay grouped as well.
Thanks alot for any help
Regards
Mark
-
grouping and ordering from a select function (reply)
Hi Martin,
Thanks for that, I have already given that a go but it does not sort the results in the way that I need. I need it to sort by price within each of the identification numbers and then move onto the next record.
Thanks again
Mark
------------
Martin at 11/15/00 11:34:24 AM
Hi,
Try something like this
select price, identification_number
from table_name
order by identification_number,price
Martin
------------
Mark Jensen at 11/15/00 11:22:34 AM
Hi, I am using MS SQL 7 on windows 2000 platform.
I have two fields getting pulled from a table and I want the results to be returned in order by price from lowest price to highest price but grouped by identification number
e.g. 1234, 2234 and 3333 are the identification numbers and the column on the left is the price
price identification number
--- -----
50 1234
60 1234
70 1234
80 1234
60 2234
70 2234
90 2234
100 2234
90 3333
120 3333
130 3333
140 3333
The main order is by price but I want the identification numbers to stay grouped as well.
Thanks alot for any help
Regards
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|