[thelist] SQL Statement problem

Wade Armstrong wade at runstrong.com
Mon Feb 11 15:51:06 CST 2002


Could you do GROUP BY 1 (where 1 is the ordinal of the term you want to
group by)?

Caveat: this may only work in t-sql, not sure if it's ansi.

Wade

on 2/11/02 1:26 PM, Seth Bienek at seth at sethbienek.com wrote:

>
> Howdy.
>
> I need to use GROUP BY to aggregate the data, and
> since I use coalesce
>
> 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
>
> The problem is that I can't group by an aliased column, right?  So I get
> errors.




More information about the thelist mailing list