Re: Need Help in QUERY
From: Prabhat (not_a_mail_at_hotmail.com)
Date: 02/18/04
- Next message: Maryam Teimourian: "Using OSQL utility"
- Previous message: Roji. P. Thomas: "Re: SQL statement with 2 tables"
- In reply to: Anith Sen: "Re: Need Help in QUERY"
- Next in thread: Uri Dimant: "Re: Need Help in QUERY"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Feb 2004 13:14:21 +0530
Thanks
But I will not know what will be the Dates and years will be there in the
database. So we can't Hardcode that in the QUERY.
Thanks
Prabhat
"Anith Sen" <anith@bizdatasolutions.com> wrote in message
news:uKMTCd48DHA.1112@tk2msftngp13.phx.gbl...
> Do:
>
> SELECT MAX(CASE YEAR(collection_dt) WHEN 2003
> THEN YEAR(collection_dt) END),
> MAX(CASE YEAR(collection_dt) WHEN 2003
> THEN MONTH(collection_dt) END),
> SUM(CASE YEAR(collection_dt) WHEN 2003
> THEN Amount END),
> MAX(CASE YEAR(collection_dt) WHEN 2002
> THEN YEAR(collection_dt) END),
> MAX(CASE YEAR(collection_dt) WHEN 2002
> THEN MONTH(collection_dt) END),
> SUM(CASE YEAR(collection_dt) WHEN 2002
> THEN Amount END)
> FROM tbl
> GROUP BY MONTH(collection_dt) ;
>
> --
> - Anith
> ( Please reply to newsgroups only )
>
>
- Next message: Maryam Teimourian: "Using OSQL utility"
- Previous message: Roji. P. Thomas: "Re: SQL statement with 2 tables"
- In reply to: Anith Sen: "Re: Need Help in QUERY"
- Next in thread: Uri Dimant: "Re: Need Help in QUERY"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|