Jump to content

Translation of excel IF to SQL


Jackiebalb0a
 Share

Recommended Posts

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. I

At the moment i have wrote it into the WHERE Clause but when i run it only returns the data which applies to the product description. 

Because of the way my where clause is set up it mean i only get half results where as i want it to show if column a does not match criteria then look for certain items in column b

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

Current SQL

SELECT 

AEOrdersReceivedCurrentQuarter.`Order Company`
, AEOrdersReceivedCurrentQuarter.`Sop Order Number`
, AEOrdersReceivedCurrentQuarter.`Order Date`
, AEOrdersReceivedCurrentQuarter.`Order Method`
, AEOrdersReceivedCurrentQuarter.`Payment Method`
, AEOrdersReceivedCurrentQuarter.`Product Type`
, AEOrdersReceivedCurrentQuarter.`Product Sub Type`
, AEOrdersReceivedCurrentQuarter.`Product Description`
, AEOrdersReceivedCurrentQuarter.`Quantity Ordered`
, AEOrdersReceivedCurrentQuarter.`Product Item Value`
, AEOrdersReceivedCurrentQuarter.`Order Count`
, AEOrdersReceivedCurrentQuarter.`Order Item Narrative`
, AEOrdersReceivedCurrentQuarter.`Product Group`
, AEOrdersReceivedCurrentQuarter.`Product Category`

FROM AEOrdersReceivedCurrentQuarter.csv AEOrdersReceivedCurrentQuarter

WHERE 
(AEOrdersReceivedCurrentQuarter.`Product Type` = 'Studio Services' OR AEOrdersReceivedCurrentQuarter.`Product Description` IN ('Artwork Charge','Creative Services','Creative Agency','Studio Services') )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...