Re: need help in building a query

Поиск
Список
Период
Сортировка
От Frank Bax
Тема Re: need help in building a query
Дата
Msg-id 4914AC78.8050805@sympatico.ca
обсуждение исходный текст
Ответ на Re: need help in building a query  ("Devil™ Dhuvader" <gibsosmat@gmail.com>)
Ответы Re: need help in building a query  ("Devil™ Dhuvader" <gibsosmat@gmail.com>)
Список pgsql-sql
Devil™ Dhuvader wrote:
>   its like sum up entries of each user in order table backwards (i.e 
> from last entry to the first) and find the entry that has sum > $500.
> If there is some user who didnt even make 500 till now in my shop return 
> the first date of transaction/order .
> 
> ex:
> Orders(order_id, user_id, amount_paid, create_timestamp)
> values:
> (1, 1, 100, 1)
> (2, 1, 300, 2)
> (3, 2, 100, 2)
> (4, 2, 100, 3)
> (5, 1, 100, 4)
> (6, 1, 200, 5)
> (7, 2, 150, 5)
> 
> for user 1: the order_id = 2
> for user 2: the order_id = 3 (coz he couldnt make 500)


I might also take a crack at the SQL if I understood the question; but I 
still don't know what you want.  You're initial question indicated you 
were trying to calculate the proper discount for each customer.  This 
example mentions neither customers nor discounts at all and appears to 
be looking for a specific transaction instead.

Frank


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Osvaldo Kussama"
Дата:
Сообщение: Resp.: need help in building a query
Следующее
От: "Devil™ Dhuvader"
Дата:
Сообщение: Re: need help in building a query