Re: need help in building a query - Mailing list pgsql-sql

From Harold A. Giménez Ch.
Subject Re: need help in building a query
Date
Msg-id c807ef1a0811060910y3dcd01d0yd4ea3dd5c26061b9@mail.gmail.com
Whole thread Raw
In response to Re: need help in building a query  ("Devil™ Dhuvader" <gibsosmat@gmail.com>)
Responses Re: need help in building a query
List pgsql-sql
I personally would help if I understood what you need. I'm sure others feel the same way. Provide DDL, sample data, and
expectedresult of the query. Maybe you'll have better luck...<br /><br /><div class="gmail_quote"> On Thu, Nov 6, 2008
at11:15 AM, Devil™ Dhuvader <span dir="ltr"><<a href="mailto:gibsosmat@gmail.com">gibsosmat@gmail.com</a>></span>
wrote:<br/><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left:1ex;"> none can help me? <br /><br /><div class="gmail_quote">On Tue, Nov 4, 2008 at 9:08 PM, Devil™
Dhuvader<span dir="ltr"><<a href="mailto:gibsosmat@gmail.com" target="_blank">gibsosmat@gmail.com</a>></span>
wrote:<br/><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left:1ex;"><font color="midnightblue" face="Verdana, Arial, Helvetica" size="2"><span>hi,<br />I need some help
increating a sql.<br />the problem is as below.<br /><br />assume that:<br />I am a store keeper <br /> and I have the
listof customer(user_id) transactions in my order table.<br />schema: Orders(order_id, user_id, amount_paid,
create_timestamp)<br/><br />I want to give discount of 10% for the customer who made orders of worth (sum) at least
$500in the least time from now (i.e last few days, but NOT ALL TIME LEAST TIME TO BUY $500 WORTH GOODS).<br />and 9%
discountfor the customer who made $500 in second least time from now.<br />and so on<br /><br /></span></font><font
color="midnightblue"face="Verdana, Arial, Helvetica" size="2"><span>there is no time constraint.<br /> it customer
couldtake any amount of time to make $500.<br />the customer might not even made $500 bill till now in that case I
shouldget the first date.<br /><br />the result can take upto the first entry time of the table itself.<br /><br />in
shortits like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the
entrythat has sum > $500. <br />If there is some user who didnt even make 500 till now in my shop return the first
dateof transaction/order</span></font>.<br /><br />can anyone help me on this? </blockquote></div><br
/></blockquote></div><br/> 

pgsql-sql by date:

Previous
From: "Devil™ Dhuvader"
Date:
Subject: Re: need help in building a query
Next
From: Andreas Joseph Krogh
Date:
Subject: Finding all tables that have foreign keys referencing a table