Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Informix SQL Query

Status
Not open for further replies.

Jamie2002

Technical User
Sep 17, 2001
62
GB
I need some assistance in writing a query, using Informix SQL that will, for each customer sum the amount they have spent in the FIRST 3 months AFTER they registered.

I am finding it difficult to do this in Informix. Using Oracle I would probably use the MONTHS_BETWEEN function. Is there anything similar to this in Informix. I would be grateful if anyone can give me any ponters on this.

The query looks something like this:

Select client.accountnum, client.opendate, sum(transaction.amount)
from clients, transactions
where clients.accountnum = transactions.accountnum
??? and transactions.date between client.opendate and ???
group by 1, 2

Hope this makes sense!
Thanks

Jamie
Thanks

Jamie
 
Jamie:

Informix has month, day, and year functions which work on an informix date or datetime so can do this:

Select client.accountnum, client.opendate, sum(transaction.amount)
from clients, transactions
where clients.accountnum = transactions.accountnum
and transactions.date between client.opendate and
month(transactions.date) > 3
group by 1, 2

You probably want something like the above?

Regards,

Ed
Schaefer
 
Hi Jamie,

You can use this query,

Select client.accountnum, client.opendate, sum(transaction.amount)
from clients, transactions
where clients.accountnum = transactions.accountnum
and (client.opendate + 3 unit months)>= transactions.date
group by 1, 2;

G.R.P.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top