Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Next CASE Statements
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01434983
Message ID:
01434986
Vues:
47
>I'm trying to covert this MS Access query to SQL:
>
>
>SELECT  MOS_OLPHKEY
>              MOS_OLREFNO
>             Sum(IIf(MOS_STATUS=4,0,IIf(MOS_STATUS=3,IIf(MOS_QTY_REC>MOS_QTY,MOS_QTY,MOS_QTY_REC),MOS_QTY))) AS [Booked Qty]
>FROM MOS
>GROUP BY MOS_OLPHKEY, MOS_OLREFNO
>
>
>Here's what I have, but I don't it's not right. I could use some help with the syntax:
>
>
>
>SELECT  MOS_OLPHKEY
>              MOS_OLREFNO, 
>              CASE MOS_STATUS 
>                  WHEN 4 THEN 0
>                  WHEN 3 THEN 
>                     CASE WHEN MOS_QTY_REC > MOS_QTY THEN
>                           MOS_QTY
>                     ELSE
>                           MOS_QTY_REC
>                     END
>                   ELSE
>                          MOS_QTY
>                   END as AS [Booked Qty]
>	FROM MOS
>	GROUP BY MOS_OLPHKEY, MOS_OLREFNO
>
IMHO you translated the code correctly, just probably need to add the name of the field as I did.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform