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!

Ordering in SQL

Status
Not open for further replies.

jammerdk

Technical User
Aug 16, 2001
51
0
0
DK
Hi I'm trying to get my Query to my records hope you guys can help me out :eek:)

My Sql looks like this

SELECT (SELECT Count(*) FROM Rapport WHERE [ID] < List.ID And Left(List.[Measuring],2) = Left(Rapport.[Measuring],2))+1 AS No, Left(List.[Measuring],2) AS Measured, List.Values
FROM Rapport AS List
ORDER BY List.ID, 2;

this gives me the following result


No Measured Values
1 OD 31,9935963027155
2 OD 31,9101684512284
3 OD 37,0079030076849
4 OD 32,0239531647089
5 OD 32,0517238454736
1 ID 21,9935963027155
2 ID 21,9101684512284
3 ID 22,0079030076849
4 ID 22,0239531647089
5 ID 22,0517238454736
6 OD 31,9935963027155
7 OD 31,9101684512284
8 OD 37,0079030076849
9 OD 32,0239531647089
10 OD 32,0517238454736
6 ID 21,9935963027155
7 ID 21,9101684512284
8 ID 22,0079030076849
9 ID 22,0239531647089
10 ID 22,0517238454736


what I like it to do is

No Measured Values
1 OD 31,9935963027155
2 OD 31,9101684512284
3 OD 37,0079030076849
4 OD 32,0239531647089
5 OD 32,0517238454736
6 OD 31,9935963027155
7 OD 31,9101684512284
8 OD 37,0079030076849
9 OD 32,0239531647089
10 OD 32,0517238454736
1 ID 21,9935963027155
2 ID 21,9101684512284
3 ID 22,0079030076849
4 ID 22,0239531647089
5 ID 22,0517238454736
6 ID 21,9935963027155
7 ID 21,9101684512284
8 ID 22,0079030076849
9 ID 22,0239531647089
10 ID 22,0517238454736
 
Change

ORDER BY List.ID, 2;

to

ORDER BY 2 DESC, List.ID

John
 
Replace this:
ORDER BY List.ID, 2;
with this:
ORDER BY 2 DESC, 1 ASC;

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks John...just what I wanted :eek:)

thanks guys for helping me out!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top