mardi 26 février 2019

How to translate my Excel If statement into the SQL Query

I am having a small issue translating my excel if statement into a CASE clause. Bellow I have posted my current SQL statement and the IF statement i am trying to fit in. Ideally i would like it to sit in the Where clause but if i need another column i will take that. Highlighted in bold is a different header.

Because of the way my where clause is set up it mean i only get half results

IF Statement is =IF(PD="AC","S",IF(PD="CS","S",IF(PD="CA","S",IF(**PT="SS","S"," ")**)))

Current SQL

SELECT 

`O C`
,`S O N`
,`O D`
,`O M`
,`P M`
**,`PT`**
,`P S T`
**,`PD`**
,`Q O`
,`P I V`
,`O C`
,`O I N`
,`P G`
,`P C`

FROM AEORCQ

WHERE (`PT` IN ('Misc','SS'))
AND (`PD` IN ('AC','C','C','S'))

Aucun commentaire:

Enregistrer un commentaire