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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 What is wrong with this derived table query

Author  Topic 

craigwg
Posting Yak Master

154 Posts

Posted - 2011-04-21 : 16:08:24
I get an error message. The derived table runs fine, but I don't understand why this is erroring on the ")".


select invoicetotal
from (
select invoicetotal = max(invoicetotal)
from ap..invoices
where paymentdate is null
group by vendorid
)


Craig Greenwood

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-21 : 16:11:41
[code]select invoicetotal
from (
select invoicetotal = max(invoicetotal)
from ap..invoices
where paymentdate is null
group by vendorid
) as table_alias[/code]Derived tables require an alias if they're part of the FROM clause, including a JOIN condition.
Go to Top of Page

craigwg
Posting Yak Master

154 Posts

Posted - 2011-04-21 : 16:37:32
ahhhhh. Thanks. That did it.

Craig Greenwood
Go to Top of Page
   

- Advertisement -