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!

nexted query not working

Status
Not open for further replies.

hyy1109

IS-IT--Management
Dec 16, 2002
27
US
I have the following nested query. The second select sum(amount) works by itself. But, the whole query not working. Please help. Thanks.

SELECT *
FROM (select sum(amount) amount, leaseid, accntyearmonth, loscode from leaselos where specialtype='Net' group by leaseid, loscode,accntyearmonth )
 
The subquery may need an alias.
Code:
SELECT *
  FROM (select sum(amount) amount, leaseid, accntyearmonth, loscode from leaselos  where  specialtype='Net' group by leaseid, loscode,accntyearmonth ) aNameForTheSubquery

For future reference and with more difficult problems, you may wish to post the error message such as

Incorrect syntax near ')'

"It doesnt work" doesnt give us much to go on.
 
yes, Incorrect syntax near ')'. Now it is working like a charm after adding an alias. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top