Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select TOP 1 on two fields
Message
De
25/02/2023 07:09:59
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
25/02/2023 06:15:56
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01686062
Message ID:
01686268
Vues:
48
>This will be make two order by with two fields as independent:
>select TOP 1 CONVERT(VARCHAR(10),DATE_FLD,101) + STR(ORDER_NO), FIELD2, FIELD3 from MyTable order by DATE_FLD, ORDER_NO DESC
>
>Try this one:
>select TOP 1 CONVERT(VARCHAR(10),DATE_FLD,101) + STR(ORDER_NO), FIELD2, FIELD3 from MyTable order by 1 DESC

Is this VFP or TSQL? Because convert(..., 101) looks like TSQL, and I'm not sure „order by 1“ is allowed in TSQL. Last time I tried you had to repeat the whole expression in the order by clause.
Also, I'd make the str() use fixed with, so not to make 101 come before 2 in case the results are left aligned.

Other than that, yup, this would work, but then why not

select top 1 date_fld, order_no, field2, field3 order by date_fld desc, order_no

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform