August 6, 2009 at 3:30 pm
I am trying to combine these 2 sql querys from one table into the result set below. I am having trouble figuring out how to get one result set.
WeekEnding No of Checks No of DD's
6/14/2009 2192 979
6/21/2009 2168 948
6/28/2009 2385 977
7/5/2009 1893 907
use damian
Select convert(varchar(10),WeekEnding,101) as Weekending, count(Checknumber)as 'No of Checks' from dbo.ut_CheckData
where CheckNumber not like 'dd%' and len(checknumber) > 8 and weekending in('6/14/2009','6/21/2009','6/28/2009','7/5/2009')
group by (weekending)
use damian
Select convert(varchar(10),WeekEnding,101) as Weekending, count(WeekEnding) as 'No of DDs' from dbo.ut_CheckData
where CheckNumber like 'dd%' and weekending in('6/14/2009','6/21/2009','6/28/2009','7/5/2009')
group by (weekending)
August 7, 2009 at 6:53 am
dsimpson (8/6/2009)
I am trying to combine these 2 sql querys from one table into the result set below. I am having trouble figuring out how to get one result set.WeekEnding No of Checks No of DD's
6/14/2009 2192 979
6/21/2009 2168 948
6/28/2009 2385 977
7/5/2009 1893 907
use damian
Select convert(varchar(10),WeekEnding,101) as Weekending, count(Checknumber)as 'No of Checks' from dbo.ut_CheckData
where CheckNumber not like 'dd%' and len(checknumber) > 8 and weekending in('6/14/2009','6/21/2009','6/28/2009','7/5/2009')
group by (weekending)
use damian
Select convert(varchar(10),WeekEnding,101) as Weekending, count(WeekEnding) as 'No of DDs' from dbo.ut_CheckData
where CheckNumber like 'dd%' and weekending in('6/14/2009','6/21/2009','6/28/2009','7/5/2009')
group by (weekending)
There are probably a few ways to do this, but an easy one to start would be to use each of these queries as a derived table and then use a JOIN to put them together based on the WeekEnding field.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply