Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 8E6B69FB7B8 for ; Wed, 28 Mar 2007 16:05:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 64323-04 for ; Wed, 28 Mar 2007 16:04:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail102.cra-arc.gc.ca (mail102.cra-arc.gc.ca [198.103.184.24]) by postgresql.org (Postfix) with ESMTP id 18EF19FB551 for ; Wed, 28 Mar 2007 16:04:55 -0300 (ADT) Received: from SD07ITMB01.PROD.NET (unknown [7.32.21.166]) by mail102.cra-arc.gc.ca (mail) with ESMTP id DCF3DDD0PS for ; Wed, 28 Mar 2007 15:04:54 -0400 (EDT) Received: from SD01ITMV12.PROD.NET ([7.32.10.12]) by SD07ITMB01.PROD.NET with Microsoft SMTPSVC(6.0.3790.2499); Wed, 28 Mar 2007 15:04:30 -0400 x-mimeole: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C7716B.EA32FFCB" Subject: How too select different views using a IF/THEN/ELSE procedure ? Date: Wed, 28 Mar 2007 15:04:30 -0400 Message-ID: <7CCC5BEF5E72394C963E529B54EB4A642A199E@SD01ITMV12.PROD.NET> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How too select different views using a IF/THEN/ELSE procedure ? Thread-Index: Acdxa+oZWMoof70nQ2+Cm+E8vYjktg== From: "Wilkinson, Jim" To: Cc: "Wilkinson, Jim" X-OriginalArrivalTime: 28 Mar 2007 19:04:30.0696 (UTC) FILETIME=[EA232680:01C7716B] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/338 X-Sequence-Number: 27976 This is a multi-part message in MIME format. ------_=_NextPart_001_01C7716B.EA32FFCB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Below is a select statement that select incidents by month. I need a function or a method to select differents views that will show the Month columns is a different order. Say Apr - Mar for a fiscal year. I need to do something like an if/then/else statement that selects the correct view to use by a variable check. Any ideas what I can use or do ? select case public.incident.gender_code_id WHEN 31 THEN 'Male' WHEN 32 THEN 'Female' ELSE 'Non-Person' END, count (case extract ( month from public.incident.incident_date )WHEN 01 then 1 Else NULL END) as Jan,=20 count (case extract ( month from public.incident.incident_date )WHEN 02 then 1 Else NULL END) as Feb,=20 count (case extract ( month from public.incident.incident_date )WHEN 03 then 1 Else NULL END) as Mar,=20 count (case extract ( month from public.incident.incident_date )WHEN 04 then 1 Else NULL END) as Apr,=20 count (case extract ( month from public.incident.incident_date )WHEN 05 then 1 Else NULL END) as May,=20 count (case extract ( month from public.incident.incident_date )WHEN 06 then 1 Else NULL END) as Jun,=20 count (case extract ( month from public.incident.incident_date )WHEN 07 then 1 Else NULL END) as Jul,=20 count (case extract ( month from public.incident.incident_date )WHEN 08 then 1 Else NULL END) as Aug,=20 count (case extract ( month from public.incident.incident_date )WHEN 09 then 1 Else NULL END) as Sep,=20 count (case extract ( month from public.incident.incident_date )WHEN 10 then 1 Else NULL END) as Oct, count (case extract ( month from public.incident.incident_date )WHEN 11 then 1 Else NULL END) as Nov,=20 count (case extract ( month from public.incident.incident_date )WHEN 12 then 1 Else NULL END) as Dec, count (extract ( month from public.incident.incident_date )) as Total=20 from public.incident GROUP BY public.incident.gender_code_id ------_=_NextPart_001_01C7716B.EA32FFCB Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable How too select different views using a IF/THEN/ELSE procedure = ?

Below = is  a select statement that select incidents by month.   = I need a function or a method to select differents views that will show = the Month columns is a different  order.  Say = Apr – Mar for a fiscal year.

I = need to do something like an if/then/else statement that selects the = correct view to use by a variable check.

Any = ideas what I can use or do ?



select case = public.incident.gender_code_id

        WHEN 31 THEN 'Male'

        WHEN 32 THEN 'Female'

        ELSE 'Non-Person'

        END,

        count (case extract ( month from = public.incident.incident_date )WHEN 01 then 1 Else NULL END) as Jan, =

        count (case extract ( month from = public.incident.incident_date )WHEN 02 then 1 Else NULL END) as Feb, =

        count (case extract ( month from = public.incident.incident_date )WHEN 03 then 1 Else NULL END) as Mar, =

        count (case extract ( month from = public.incident.incident_date )WHEN 04 then 1 Else NULL END) as Apr, =

        count (case extract ( month from = public.incident.incident_date )WHEN 05 then 1 Else NULL END) as May, =

        count (case extract ( month from = public.incident.incident_date )WHEN 06 then 1 Else NULL END) as Jun, =

        count (case extract ( month from = public.incident.incident_date )WHEN 07 then 1 Else NULL END) as Jul, =

        count (case extract ( month from = public.incident.incident_date )WHEN 08 then 1 Else NULL END) as Aug, =

        count (case extract ( month from = public.incident.incident_date )WHEN 09 then 1 Else NULL END) as Sep, =

        count (case extract ( month from = public.incident.incident_date )WHEN 10 then 1 Else NULL END) as = Oct,

        count (case extract ( month from = public.incident.incident_date )WHEN 11 then 1 Else NULL END) as Nov, =

        count (case extract ( month from = public.incident.incident_date )WHEN 12 then 1 Else NULL END) as = Dec,

        count (extract ( month from public.incident.incident_date = )) as Total

from = public.incident

GROUP = BY public.incident.gender_code_id

------_=_NextPart_001_01C7716B.EA32FFCB--