| От | Tom Lane |
|---|---|
| Тема | Re: Calculating the difference between result columns |
| Дата | |
| Msg-id | 29891.1104246035@sss.pgh.pa.us обсуждение |
| Ответ на | Calculating the difference between result columns ("Keith Worthington" <keithw@narrowpathinc.com>) |
| Список | pgsql-novice |
"Keith Worthington" <keithw@narrowpathinc.com> writes:
> I'm stuck again. I have written two queries. The first calculates the total
> quantity of items that have been ordered. The second calculates the total
> quantity of items that have been received. Now I want to find the difference
> which will tell me what is still on order.
Something like
SELECT o.item_id, ordered - received FROM
(SELECT ...) o
(SELECT ...) r
WHERE o.item_id = r.item_id;
I'm not sure how efficient this mess is going to be :-(. If you intend
to do this a lot, you might want to think about a different database
structure that doesn't require quite so much joining to find out
anything...
regards, tom lane
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера