This is a discussion on How can count a column from two tables in SQL Server? within the Database Support forums, part of the Web Development category; How can count a column from two tables in SQL Server?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| I have two tables namely emp and dept which have a common column “deptno”. I need to count the deptno from those two tables. Here is the sample code. Select sum (subcount) as totalcount from ( select deptno, count(*) as subcount from emp group by deptno union all select deptno, count(*) as subcount from dept group by deptno ) |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Foreign key column | leoraja8 | Database Support | 6 | 10-15-2007 11:27 PM |
| Can I nest tables within tables? | oxygen | HTML, CSS and Javascript Coding Techniques | 2 | 07-27-2007 03:33 AM |
| What is the Query to display all tables and Database names in server use sql? | kingmaker | Database Support | 2 | 07-23-2007 10:57 PM |
| How to retrive tables name with row count:(content) | kingmaker | Database Support | 1 | 07-23-2007 07:29 AM |
| How to Create temporary tables in SQL Server 2005? | oxygen | Database Support | 2 | 07-23-2007 01:13 AM |