Re: sql question

From: Tom Best <Tom.Best_at_bentley.com>
Date: Wed, 01 Dec 1999 08:36:55 -0500
Message-ID: <38452477.28F7FEA1_at_bentley.com>


Try using something like:

    where months_between (sysdate, a.transaction_date) = 1

Tom Best

Mick Cooke wrote:

> I am having trouble with date function in a query.
> I want to generate a query that will sumall transactions for the previous
> month.
>
> e.g.
> select a.field1, sum(a.field2), b.field1,b.field2
> from table a, table b
> where a.field1= b.field3
> and a.transaction_date = [this is the problem bit] month -1
> group by b.generic_text,a.ACCOUNT_TYPE_CODE,b.long_name
>
> this runs ok when selecting specific number of days e.g
>
> select a.field1, sum(a.field2), b.field1,b.field2
> from table a, table b
> where a.field1= b.field3
> and a.transaction_date = between trunc(sysdate) and trunc(sysdate -1)
> group by b.generic_text,a.ACCOUNT_TYPE_CODE,b.long_name
>
> I'm sure this is an easy one for someone
>
> thankyou in anticipation and appreciation
>
> Mickc
Received on Wed Dec 01 1999 - 14:36:55 CET

Original text of this message