Re: [SQL] need help in building a query

2008-11-08 Thread Devil Dhuvader
> > > Try: > > bdteste=# SELECT o1.user_id, o1.order_id, '>= 500' AS cond FROM Orders o1 > bdteste-# WHERE (SELECT sum(o2.amount_paid) FROM Orders o2 WHERE > o2.user_id = o1.user_id AND o2.order_id > o1.order_id) < 500 AND > bdteste-#(SELECT sum(o2.amount_paid) FROM Orders o2 WHERE > o2.us

Re: [SQL] need help in building a query

2008-11-08 Thread Devil Dhuvader
) with limit 10. then I will give discount of 10%, 9%, .. etc. if you know ageing credit. its just like that. On Sat, Nov 8, 2008 at 2:30 AM, Frank Bax <[EMAIL PROTECTED]> wrote: > Devil™ Dhuvader wrote: > >> its like sum up entries of each user in order table backwards (i.e fro

Re: [SQL] need help in building a query

2008-11-07 Thread Devil Dhuvader
ote: > I personally would help if I understood what you need. I'm sure others feel > the same way. Provide DDL, sample data, and expected result of the query. > Maybe you'll have better luck... > > > On Thu, Nov 6, 2008 at 11:15 AM, Devil™ Dhuvader <[EMAIL PROTECTED]>

Re: [SQL] need help in building a query

2008-11-06 Thread Devil Dhuvader
none can help me? On Tue, Nov 4, 2008 at 9:08 PM, Devil™ Dhuvader <[EMAIL PROTECTED]> wrote: > hi, > I need some help in creating a sql. > the problem is as below. > > assume that: > I am a store keeper > and I have the list of customer(user_id) transactions in my or

[SQL] need help in building a query

2008-11-04 Thread Devil Dhuvader
hi, I need some help in creating a sql. the problem is as below. assume that: I am a store keeper and I have the list of customer(user_id) transactions in my order table. schema: Orders(order_id, user_id, amount_paid, create_timestamp) I want to give discount of 10% for the customer who made orde

[SQL] how to sum entries from the last entry to some entry in between dynamically?

2008-10-26 Thread Devil Dhuvader
hi, I need some help in creating a sql. the problem is as below. assume that: I am a store keeper and I have the list of customer(user_id) transactions in my order table. schema: Orders(order_id, user_id, amount_paid, create_timestamp) I want to give discount of 10% for the customer who made orde