More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
admin  
#1 Posted : Thursday, 5 March 2015 5:42:13 AM(UTC)
admin

Rank: Newbie

Reputation:

Groups: admin, Administration
Joined: 4/09/2013(UTC)
Posts: 1

Count and select distinct values from 2 union SQL Server tables

Count distinct values from 2 union SQL Server tables
Code:
SELECT COUNT(distinct tmp.col1) FROM ( (SELECT col1, col2, col3 FROM table1) 
UNION (SELECT  col1, col2, col3 FROM table2) ) as tmp


Select distinct values from 2 union SQL Server tables
Code:
SELECT distinct tmp.col1, tmp.col2, tmp.col3 FROM ( (SELECT col1, col2, col3 FROM table1) 
UNION (SELECT  col1, col2, col3 FROM table2)) as tmp

Edited by user Thursday, 5 March 2015 5:42:51 AM(UTC)  | Reason: Not specified

Sponsor
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.