tmccull2
asked on
Microsoft Query / SQL
I need help adding paramters (begindate1,enddate1,begin date2,endd ate2) to replace the hard coded dates in this sql statement. The statement below works fine in Microsoft Query and returns the data to Excel 2003. I'd like the parameters to be populated by cell values in the Excel worksheet. Thanks!
SELECT Principal, SUM(Case When Date BETWEEN '1-1-2006 00:00:00.000' AND '12-31-2006 00:00:00.000' THEN Amount else 0 end), SUM(Case When Date BETWEEN '1-1-2007 00:00:00.000' AND '12-31-2007 00:00:00.000' THEN Amount else 0 end) FROM dbo.Results GROUP BY Principal ORDER BY Principal ASC
SELECT Principal, SUM(Case When Date BETWEEN '1-1-2006 00:00:00.000' AND '12-31-2006 00:00:00.000' THEN Amount else 0 end), SUM(Case When Date BETWEEN '1-1-2007 00:00:00.000' AND '12-31-2007 00:00:00.000' THEN Amount else 0 end) FROM dbo.Results GROUP BY Principal ORDER BY Principal ASC
ASKER
Thank you for your response.
If my goal is to be able to compare two date ranges such as current 52 weeks vs. YAGO and update the dates from Excel cell values, can you offer me an example to get started?
Thanks Terry
If my goal is to be able to compare two date ranges such as current 52 weeks vs. YAGO and update the dates from Excel cell values, can you offer me an example to get started?
Thanks Terry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Regards,
Rory