| Author |
Topic |
|
mathmath
Starting Member
13 Posts |
Posted - 2009-06-29 : 03:53:09
|
| Hi All,I have data like the following:Stuff Sizes IDpen s1 100001pen s2 100002pen s3 100003pencil s1 100001pencil s3 100004pencil s5 100007pencil s2 100006ruler s7 100005ruler s8 100008....where each size is coordinate with a unique ID number;and there are 10 sizes (s1.....s10);**i need to find out the HIGHEST ID number within each categories of stuff.e.g pen (100003), pencil (10007),ruler(100008)How should I do it? Thank you all for your time. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-29 : 03:57:09
|
SELECT Stuff, MAX(ID) FROM Table1 GROUP BY Stuff E 12°55'05.63"N 56°04'39.26" |
 |
|
|
mathmath
Starting Member
13 Posts |
Posted - 2009-06-29 : 04:03:14
|
quote: Originally posted by Peso SELECT Stuff, MAX(ID) FROM Table1 GROUP BY Stuff E 12°55'05.63"N 56°04'39.26"
Thanks.But i tried using Group by and it doesnt work. something about aggregate function.ps. nice house |
 |
|
|
Mangal Pardeshi
Posting Yak Master
110 Posts |
Posted - 2009-06-29 : 04:13:28
|
quote: Originally posted by mathmathThanks.But i tried using Group by and it doesnt work. something about aggregate function.ps. nice house
Why it din't work? You din't get expected result? or any error?Mangal Pardeshihttp://mangalpardeshi.blogspot.com |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-29 : 04:13:31
|
For the provided and known sample data posted 06/29/2009 : 03:53:09my code works.If you have another scenario at home or at work (which we don't have access to), please provide all necessary information needed to assist you. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
mathmath
Starting Member
13 Posts |
Posted - 2009-06-29 : 04:56:30
|
quote: Originally posted by Peso For the provided and known sample data posted 06/29/2009 : 03:53:09my code works.If you have another scenario at home or at work (which we don't have access to), please provide all necessary information needed to assist you. E 12°55'05.63"N 56°04'39.26"
yes, it works now. I do have more columns in the table, i have export the data i need to another table before i can group by. Thanks for the help. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-29 : 04:59:55
|
You want to show more columns for same record?SELECT *FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY Stuff ORDER BY ID DESC) AS recID FROM Table1) AS dWHERE recID = 1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|