# Help on Count function [Resolved]

Posted by Vijayar under C# on 6/14/2011 | Points: 10 | Views : 1106 | Status : [Member] | Replies : 5
Hi
I am having 2 tables with different columns .

Employee with columns eid,ename,sal and

product with columns pid,pname,pdesc .My problem is i want to get the count of eid and pid as a single column without common column in tables.Is this possible if Possible help me out
ex: Count of eid=4 and count of pid=9

select Count(eid) from Employee=4
select Count(pid) from product=9

o/p
count of eid and pid=13 is my desired result

vijaya

#### Responses

Posted by: Ndebata on: 6/15/2011 [Member] Starter | Points: 50
 0 Select *,X.EmployeeCount+X.ProductCount As TotalCount from ( Select COUNT(1) EmployeeCount, (Select COUNT(1) from Product Where PID=3) ProductCount from Employee Where EID=3) as XVijayar, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Lakn2 on: 6/15/2011 [Member] Starter | Points: 25
 0 try this create procedure ca as begin declare @x int declare @y int declare @z int set @x=(select count(pid) from product) set @y=(select count(eid) from temp) set @z=@x+@y print @z endThanks&Regards LakshmiNarayana Nalluri.Vijayar, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Vijayar on: 6/15/2011 [Member] Starter | Points: 25
 0 Hi Thanks for ur answer,But i want the total for a particular id i want to see for the count where eid=3 or/and pid=3 if total eid==80 and for eid=3 the count is 7 if total pid=50 and for pid=3 the count is 10 output should be 17 vijayaVijayar, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Vijayar on: 6/15/2011 [Member] Starter | Points: 25