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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Derived Tables with aggrigate queries.

Status
Not open for further replies.

DavidJA

Programmer
Jan 10, 2002
58
AU
Hi all,

I have a query with a derived table in the from clause.

The derived table is made up of an agrigate query. FROM xyz LEFT JOIN (select min(dteDeadline) as MinDeadline, OrderID FROM tblOrderItems) is there any way that I can put a where clause in the aggrigate query and specify columsn from the main query, eg: FROM xyz LEFT JOIN (select min(dteDeadline) as MinDeadline, OrderID FROM tblOrderItems WHERE CustomerID = Customers.CustomerID)?

When I try this I get a column not found. I can of course specify the column to output in my derived table then join on it in the parent query, but I want to do the aggrigate on a column that can not be in the group by clause of the aggrigate query.
 
I don't think you can do that.
I've never been able to get the select in a derived table to refer to a column from a table 'outside the brackets'.

You want it work like a subquery in that regard, but I guess it doesn't.

bperry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top