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 |
|
cloudy007
Starting Member
1 Post |
Posted - 2007-06-05 : 08:29:00
|
Hi all,I hope someone can help me with this problem, cos I'm a bit lost. We have a system and its needs to check whether an employee is assigned to a Group or not. With one table, its not a problem.Select Count(CardID) from Table Where GroupID is Null.Now we created a different table for different Employees.I basically need to do the followingSelect Count(CardID) as HRCount from Table1 Where etc, etcSelect Count(CardID) as FPCount From Table2 Where etc, etcHowever I need ONE total, if possible at once.There is no relation between the tables.To SUM it up, I need ONE total from TWO separate tables.Is it possible?Thanks and RegardsClaudio |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-05 : 08:31:39
|
| selcet * from (Select count1 = Count(CardID) as HRCount from Table1 Where etc, etc) across join(Select count2 = Count(CardID) as FPCount From Table2 Where etc, etc) borSelect count1 = Count(CardID) as HRCount from Table1 Where etc, etcunion allSelect Count(CardID) as FPCount From Table2 Where etc, etcorselect sum(count1) from (Select count1 = Count(CardID) as HRCount from Table1 Where etc, etcunion all(Select count2 = Count(CardID) as FPCount From Table2 Where etc, etc) a==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-05 : 08:34:59
|
| Select sum(HRCount ) from(Select Count(CardID) as HRCount from Table1 Where etc, etcunion allSelect Count(CardID) From Table2 Where etc, etc) s--------------------------------------------------S.Ahamed |
 |
|
|
|
|
|
|
|