[thelist] SQL Statement problem

Howard Cheng howcheng at ix.netcom.com
Mon Feb 11 15:51:27 CST 2002


I know in MS SQL Server you can't group by an alias. In this case, your
only solution is to use the same function in your GROUP BY clause.

In other words,

SELECT
         COALESCE(...)
FROM ...
GROUP BY
         COALESCE(...)

At 03:26 PM 2/11/2002 -0600, Seth Bienek wrote:
>SELECT
>         COALESCE (DATEPART(ww, approved_date), DATEPART(ww,
> terminate_date)) AS
>status_date,
>         COUNT(approved_date) AS apdate,
>       COUNT(terminate_date) AS tdate
>FROM
>         applications
>WHERE
>         company_key = 'LI'
>         AND
>         (approved_date BETWEEN '01/01/2001' AND '01/01/2002')
>         OR
>         (terminate_date BETWEEN '01/01/2001' AND '01/01/2002') AND
> (terminate_type =
>'declined')
>GROUP BY
>         status_date

::::::::::::::::::::::
Howard Cheng
howcheng at ix.netcom.com
AIM: bennyphoebe
ICQ: 47319315




More information about the thelist mailing list