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.
| Author |
Topic |
|
label
Posting Yak Master
197 Posts |
Posted - 2003-09-20 : 11:00:31
|
Not that anyone's actually here on a Saturday, but just in case: Why isn't this Select working? It seems like a straight forward query but I must be overlooking some simple syntax issue.....select distinct(damage) from select primaryDamage as damage from aims.dbo.WebSalelist a join aims.dbo.sale b on a.saleID=b.saleID where b.yardid=1 and primarydamage is not null group by primaryDamage union all select secondaryDamage as damage from aims.dbo.WebSalelist a join aims.dbo.sale b on a.saleID=b.saleID where b.yardid=1 and secondaryDamage is not null group by secondaryDamage |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-09-20 : 11:23:16
|
| select distinct(damage) from ( select primaryDamage as damage from aims.dbo.WebSalelist a join aims.dbo.sale b on a.saleID=b.saleID where b.yardid=1 and primarydamage is not null group by primaryDamage union all select secondaryDamage as damage from aims.dbo.WebSalelist a join aims.dbo.sale b on a.saleID=b.saleID where b.yardid=1 and secondaryDamage is not null group by secondaryDamage ) DSubqueries must be aliased, even if you do not need to use the alias in the outer SELECT statement. |
 |
|
|
label
Posting Yak Master
197 Posts |
Posted - 2003-09-20 : 11:37:03
|
quote: Originally posted by robvolk select distinct(damage) from ( select primaryDamage as damage from aims.dbo.WebSalelist a join aims.dbo.sale b on a.saleID=b.saleID where b.yardid=1 and primarydamage is not null group by primaryDamage union all select secondaryDamage as damage from aims.dbo.WebSalelist a join aims.dbo.sale b on a.saleID=b.saleID where b.yardid=1 and secondaryDamage is not null group by secondaryDamage ) DSubqueries must be aliased, even if you do not need to use the alias in the outer SELECT statement.
Great, that worked perfectly. I knew I was overlooking something minor. Thanks! |
 |
|
|
|
|
|