|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
CASE Syntax help
Basically I want to do math in the case statement.
The org and cur fields are dollar amounts. The 1.0, and .05 amounts come from another field, but I put them there for testing purposes. I am new to SQL so I am sorry if I am way off here and this doesn't make any since. My question is also, where would the result of the case be stored? Can I put the result in my own field? Do I have to use a field in the file to store the result? SELECT pnacct, case when ((pncshorg - pncshcur) < (1.0 * pncshorg)) then (pncshorg - pncshcur) else 0 END, case when ((pnqasorg - pnqascur) < (.05 * pnqasorg)) then (pnqasorg - pnqascur) else 0 END, case when ((pnnasorg - pnnascur) < (.05 * pnnasorg)) then (pnnasorg - pnnascur) else 0 END, case when ((pnnrsorg - pnnrscur) < (.05 * pnnrsorg)) then (pnnrsorg - pnnrscur) else 0 END, case when ((pnpsrorg - pnpsrcur) < (.05 * pnpsrorg)) then (pnpsrorg - pnpsrcur) else 0 END FROM FILENAME WHERE PNDCLNO = 100078 GROUP BY PNACCT |
|
#2
|
||||
|
||||
|
give each of those an alias after the END.
__________________
MySQL - reformat varchar dates to proper date type || MySQL - room vacancies || output results with column names with mysql only Latest row per group || Deleting duplicates || Gaps in auto increment column My site: sql help articles |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > CASE Syntax help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|