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!

Is there a way to sort this...? 1

Status
Not open for further replies.

dcwave

IS-IT--Management
May 18, 2003
46
US
Code:
SELECT sales.RSMID, rsm.FName, rsm.LName, sales.ID AS SalesID, sales.DateSold, sales.CustName, sales.SysConfig, host.HostName, salestype.SaleType, sales.Amount, [b](Select Sum(B.Amount) From Sales B Where B.RSMID=Sales.RSMID AND Month(B.DateSold)=1) AS MTD[/b], sales.Margin, rsm.Goal

FROM ((rsm INNER JOIN sales ON rsm.ID = sales.RSMID) INNER JOIN host ON sales.HostVend = host.ID) INNER JOIN salestype ON sales.Type = salestype.ID

GROUP BY sales.RSMID, rsm.FName, rsm.LName, sales.ID, sales.DateSold, sales.CustName, sales.SysConfig, host.HostName, salestype.SaleType, sales.Amount, sales.Margin, rsm.Goal

HAVING Month(DateSold)=1

I need to Order by MTD.
When ever I try I get a syntax error. I've tried ORder By after the Having and I've tried inside the sub query - no luck.

Thanks
 
ORDER BY 11;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
What does the "11" correspond to?
 
The 11th field in the SELECT clause.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks. I didn't know you could just count the number of fields and order by their number.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top