June 7, 2011 at 4:09 am
Got simple query:
SELECT Department, Tax_Year, Tax_Period, Total_Bill, Total_Hours, Purchase_Order_Number
FROM Timesheets
WHERE (Department = '971') AND (Tax_Year = '2010') AND (Tax_Period > '41')
I want to change this so it does a total_bill for each different Purchase_Order_Number Number for all timesheets between Tax_Week 41 and Tax_Year 2009
and Tax_Week 40 and Tax_Year 2010 for Department 971
When i do it i am only getting data > tax week 41 and less than week 40. It mjisses out tax year 1,2,3 ext for the higher year.
Sorry this is so basic but teaching myself.
Thanks for any help
June 7, 2011 at 4:26 am
You can try this to see if you filter the correct data:
SELECT
Department,
Tax_Year,
Tax_Period,
Total_Bill,
Total_Hours,
Purchase_Order_Number
FROM Timesheets
WHERE
(Department = '971')
AND (
( (Tax_Year = '2009') AND (Tax_Period >= '41') )
OR
( (Tax_Year = '2010') AND (Tax_Period <= '40') )
)
Regards,
Iulian
June 7, 2011 at 4:31 am
Thank you so much this works! I now need to sum the charge per purchase order number wish me luck!!!
June 7, 2011 at 4:35 am
I wish you luck! 🙂 post if you get stucked
Regards,
Iulian
June 7, 2011 at 5:13 am
Please don't cross post. It just wastes people's time and fragments replies
No replies to this thread please. Direct replies to http://www.sqlservercentral.com/Forums/Topic1120833-391-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply