Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select with case when
Message
De
07/06/2001 08:27:37
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/06/2001 08:24:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00516210
Message ID:
00516244
Vues:
16
>>Hello All,
>>
>>I'm trying to use a case when in this select to order classifications. The grades available, in order of importance are A+,A,B+,B,C+,C.
>>
>>I want to create a select that will translate these so a report can be ordered by importance.
>>
>>This returns an error message:
>>
>>
>>Select name, sire1, case when grade = "A+" then "1", grade = "A" then "2", grade = "B+" then "3" end as gradeorder from master where grade <> " " order by name
>>
>>Any help would be appreciated.
>>
>>Jim Harvey
>>jharvey@netrax.net
>
>James,
>SQL server does that but this kind of case is not allowed in VFP SQL.
>You could do something like :
>
>
Select name, sire1, ;
>  iif(grade = "A+",1,;
>  iif(grade = "A",2,;
>  iif(grade = "B+",3,;
>  iif(grade = "B",4,;
>  iif(grade = "A",2,;
>))))) as gradeorder from master where grade # " " order by name
Cetin

This would work for little list like this one however if it's long then better you create a cursor for it and do a join.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform