Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
what is wrong with my syntax? I am trying to do a select from another selectSelect * from A (SELECT Col1, Col2,'DP3' as Location FROM myTable00 union SELECT Col1, Col2, 'Sql' as Location FROM myTable99) as Aafter i do the outer select can i group on, or do Max(Col1) for example?
iancuct
Yak Posting Veteran
73 Posts
Posted - 2005-01-20 : 10:41:09
Select A.* from ( SELECT Col1, Col2,'DP3' as Location FROM myTable00 union SELECT Col1, Col2, 'Sql' as Location FROM myTable99) as AOk i figured it out myself .. I am bad with parenthasis
X002548
Not Just a Number
15586 Posts
Posted - 2005-01-20 : 11:54:34
Nice naming convention...I think you might want to Use UNION ALL..UNION Will through out duplicates and incur a sort
SELECT Col1, Col2, Location FROM ( SELECT Col1, Col2, 'DP3' as Location FROM myTable00 UNION ALL SELECT Col1, Col2, 'Sql' as Location FROM myTable99 ) AS XXX
Brett8-)EDIT: Oh and use [ code] [ /code ] tags with out the space to keep the code format