Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
roer
Starting Member
2 Posts |
Posted - 2008-04-22 : 09:54:09
|
| I have a table which tracks changes by user, department and date. I want to construct a query which returns two numbers, the first is all the changes by department on a certain date. The second is all changes by user on the same date. I know that the queries seperately will look like,SELECT COUNT(User) As NumberByUserFROM TableWHERE (Date = 'DateGoesHere') AND (User= 'UserGoesHere')GROUP BY UserSELECT COUNT(Department) As NumberByDepartmentFROM TableWHERE (Date = 'DateGoesHere') AND (Department = 'DepartmentGoesHere')GROUP BY DepartmentBut how do I go about linking the two in the same query? Any help would be appreciated, thanks! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-22 : 10:02:10
|
{query 1}UNION ALL{query 2} E 12°55'05.25"N 56°04'39.16" |
 |
|
|
roer
Starting Member
2 Posts |
Posted - 2008-04-22 : 10:05:11
|
| Worked perfectly, thanks! |
 |
|
|
|
|
|