May 10, 2016 at 1:59 am
Hello
I am trying to exclude from my query rows where Code is either 'GST', 'TAX', 'COMM' and
rows where Ty is 'A' and 'C' but only where it is also Cr Ind = 'C'
This is what I have but I know it is not quite right. Can anyone shed light on what I am doing wrong.
Thanks
SELECT [Emp Number], SUM(Amount) FROM [" & PayrollSheetName & "$] " & _
" WHERE Code NOT IN ('GST','TAX', 'COMM') " & _
" AND (Ty NOT IN ('A','C') AND [Cr Ind] = 'C') " & _
" GROUP BY [Emp Number] "
Thanks Brian
You are never an expert, you are always learning!May 10, 2016 at 2:07 am
Try this:
WHERE
Code NOT IN ('GST','TAX', 'COMM')
AND NOT (Ty IN ('A','C') AND [Cr Ind] = 'C'))
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
May 10, 2016 at 2:19 pm
SELECT [Emp Number], SUM(Amount) FROM [" & PayrollSheetName & "$] " & _
" WHERE Code NOT IN ('GST','TAX', 'COMM') AND Ty NOT IN ('A','C') AND [Cr Ind] = 'C')
" GROUP BY [Emp Number] "
will try this.
May 10, 2016 at 7:45 pm
Thankyou Chris, that was giving me a headache.
Thanks Brian
You are never an expert, you are always learning!Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply