Subject | Re: [firebird-support] Get ID of record with minsort |
---|---|
Author | liviuslivius |
Post date | 2015-06-25T07:35:36Z |
W dniu 2015-06-25 09:18:48 użytkownik Josef.Gschwendtner@... [firebird-support] <firebird-support@yahoogroups.com> napisał:
Hi,
I have a table with one ID-Column and one Sort-Column.
I need the ID from the record with the lowest sort-number.
Sortnumbers are not unique (can be doubled).
Can I do this with one SQL-Statement?
Thank you for your help.
Regards,
JosefHi,simplest if i understand you corectlySELECTT.FLD_ID, T.FLD_SORT, (SELECT FIRST 1 T2.FLD_ID FROM TEST T2 WHERE T2.FLD_ID=T.FLD_ID ORDER BY T2.FLD_SORT)FROMTEST Tor maybe you want?SELECTDISTINCT (SELECT FIRST 1 T2.FLD_ID FROM TEST T2 WHERE T2.FLD_ID=T.FLD_ID ORDER BY T2.FLD_SORT)FROMTEST Tbut you got only 1 ID record if sort column will be doubledregards,Karol Bieniaszewski