|
Posted by k4 on 11/14/06 01:18
I have a database that contains a column for UnitName , BeginDate and
EndDate.
I want to pass two parameters (@BeginDate and @EndDate) and retrieve a
table of values
that include UnitName along with Counts for each UnitName.
SELECT UnitName, COUNT(BeginDate) AS Start
(SELECT COUNT(EndDate) AS Finish WHERE EndDate BETWEEN @BeginDate AND
@EndDate)
FROM Table
WHERE BeginDate BETWEEN @BeginDate AND @EndDate
GROUP BY UnitName
ORDER BY UnitName
This works. But when I try to add another count by using a subselect I
get an error dealing with GROUP BY not including the column in my
subselect.
How is the best way to Count two columns using Group By.
Navigation:
[Reply to this message]
|