Jump to content
Sign in to follow this  
Jackiebalb0a

Translation of excel IF to SQL

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') )

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...