Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with aliases in a query

Status
Not open for further replies.

bardley

Programmer
May 8, 2001
121
US
I need a query that looks like this:
Code:
select ??? from (
 select substr(timestamp,0,10) 
 from table1 
 where substr(timestamp,0,10) < '2001-11-02'
 and substr(timestamp,0,10) > '2001-10-26'
 union all
 select substr(timestamp,0,10) 
 from table2 
 where substr(timestamp,0,10) < '2001-11-02'
 and substr(timestamp,0,10) > '2001-10-26'
) 
group by ???
order by 1
I don't know how to give the single column from the inner query an alias so I can reference it from the outside query (hence the ???). In the SQL forum, I was advised to use &quot;AS Q&quot; after the inner query, but tried it in SQL+ and got errors.

Thanks to anyone who can help! Brad Gunsalus
Cymtec Systems, Inc.
bgunsalus@cymtec.com
 
Try the same without AS:

select q from (
select substr(timestamp,0,10) q
from table1
....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top