problem with date range - Mailing list pgsql-general

From Kevin Heflin
Subject problem with date range
Date
Msg-id Pine.LNX.4.10.10001141702540.26735-100000@mercury.shreve.net
Whole thread Raw
List pgsql-general
have a query like so:

select crimeid, areaid,
sum( CASE when dateof='1-8-2000' then total else 0 end) as crimes1
from stats GROUP BY crimeid, areaid;


This works and gives me results like I want like so:

crimeid|areaid|crimes1
-------+------+-------
      4|     2|      0
      5|     2|      0
      5|     3|     20
      6|     2|      0
      7|     2|      0
      8|     2|      0
      9|     2|      0
     10|     2|      0
     11|     2|      0
     12|     2|      0



But what I really need would be the same query as above but give me
results which show total crimes for the Current year to date, and also
total crimes for 'last week'

Im wanting 'last week' to be the last complete week. Say today is
01/14/2000 the last complete week would be 01/02/2000 --> 01/08/2000

Any suggestions would be appreciated.


Kevin









--------------------------------------------------------------------
Kevin Heflin          | ShreveNet, Inc.      | Ph:318.222.2638 x103
VP/Production         | 333 Texas St #175    | FAX:318.221.6612
kheflin@shreve.net    | Shreveport, LA 71101 | http://www.shreve.net
--------------------------------------------------------------------


pgsql-general by date:

Previous
From: Ed Loehr
Date:
Subject: [GENERAL] GRANT ALL ON * TO username?
Next
From: The Hermit Hacker
Date:
Subject: Re: [GENERAL] cgi with postgres