Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL and Ranges
Message
From
31/07/2000 21:35:30
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00398875
Message ID:
00399087
Views:
13
>Using a SQL statement, I like to be able to to look at a field and if it's in a certain range, have it give a code in another field. Lets say grades for example, range 90 to 100 'A', 80-89 'B', 70-79 'C'. So if numgrade = 89, i like to have alphagrade = 'B'
>
>TIA,
>
>Jim
SELECT ;
    IIF(BETWEEN(nGrade, 90, 100), "A", ;
    IIF(BETWEEN(nGrade, 80, 89), "B", ;
    IIF(BETWEEN(nGrade, 70, 79, "C", "D")))) AS cLetterGrade, ;
    ....
If you are SELECTing against an SQL database you will need:
cMySQL = [SELECT CASE ] + ;
    [WHEN nGrade BETWEEN 90 AND 100 THEN "A" ] + ;
    [WHEN nGrade BETWEEN 80 AND 89 THEN "B" ] + ;
    [WHEN nGrade BETWEEN 70 AND 79 THEN "C" ] + ;
    [ELSE "D" END AS cLetterGrade ] + ;
    [...]
Previous
Reply
Map
View

Click here to load this message in the networking platform