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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Count across 2 tables

Author  Topic 

lsulindy
Starting Member

9 Posts

Posted - 2008-11-14 : 10:52:40
I have the following COUNT statement nested within a SELECT:

COUNT(*) FROM Employee e where right(e.ssn,6) = @id

Now I want it to count across two tables. I have an Applicant table and an Employee table. They both have ssn fields. They are not joined in any way. One is a table of applicants, one of hired employees. I want the count of applicants + employees where right(ssn,6) = @id

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-14 : 11:01:14
not joined? so you mean no relation between them? then just use

(select count(applicantfield) from table1 where right(ssn,6) = @id)+(select count(employeefield) from table2 where right(ssn,6) = @id)

cant suggest anything more without seeing your query
Go to Top of Page
   

- Advertisement -