Order By With Agregates??

Order By With Agregates??

am 19.09.2006 16:55:01 von AJ

Hi All,

I have the following query:
SELECT
ID, First(Company_Name) AS Company, First([level]) AS pkgLevel,
First(QueryNbr) AS QueryN
FROM
CompaniesByName
GROUP BY
ID

What i need to do is add an order by clause!
Essentially i need to order by the 4 & 2 columns ASC.

I don't know how to refer to these columns when using aggregate functions.

Is this possible?

Help, thoughts..appreciated!!!!!

Cheers,
Adam

Re: Order By With Agregates??

am 19.09.2006 17:09:57 von reb01501

AJ wrote:
> Hi All,
>
> I have the following query:
> SELECT
> ID, First(Company_Name) AS Company, First([level]) AS pkgLevel,
> First(QueryNbr) AS QueryN
> FROM
> CompaniesByName
> GROUP BY
> ID
>
> What i need to do is add an order by clause!
> Essentially i need to order by the 4 & 2 columns ASC.
>
> I don't know how to refer to these columns when using aggregate
> functions.
>
> Is this possible?
>
> Help, thoughts..appreciated!!!!!
>
What database??

Have you tried
Order By 4,2
?

If your database does not support that, then do:

Order By First(QueryNbr),First(Company_Name)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

RE: Order By With Agregates??

am 19.09.2006 17:13:03 von AJ

How i got around it?

SELECT ID, Company, pkgLevel, QueryN
FROM (SELECT
ID, First(Company_Name) As Company, First([level]) AS pkgLevel,
First(QueryNbr) AS QueryN
FROM
ExhibitorsByName
GROUP BY
ID
)
ORDER BY QueryN, Company;