Re: Need Help in QUERY

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Prabhat (not_a_mail_at_hotmail.com)
Date: 02/18/04


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 )
>
>



Relevant Pages

  • Re: print or select limits
    ... PRINT is not an SQL ... It is not used to query the database; ... Anith ...
    (comp.databases.ms-sqlserver)
  • Re: Need Help in QUERY
    ... database. ... So we can't Hardcode that in the QUERY. ... > - Anith ...
    (microsoft.public.sqlserver.programming)
  • Re: DBMS and lisp, etc.
    ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
    (comp.lang.lisp)
  • Re: OT: SQL
    ... query processing. ... FROM Employees e, Employees m, Management mgt ... Manager and Employee Salaries. ... The scheme used does not model database files in general, ...
    (sci.logic)
  • Re: access 2003
    ... I removed the parameters from the form query source. ... boxes from the form header, events, code, etc and ran the form query source ... forms queries and the SQL because syntax of the SQL will change randomly. ... the Access 97 database, I wouldn't have thought any expressions would be ...
    (microsoft.public.access.conversion)