Re: Combine query views into one SQL string

Поиск
Список
Период
Сортировка
От eimas@lycos.com (Eimas)
Тема Re: Combine query views into one SQL string
Дата
Msg-id 63e57aa8.0109091520.4f975abd@posting.google.com
обсуждение исходный текст
Ответ на Re: Combine query views into one SQL string  ("Maik" <K.Maik@web.de>)
Список pgsql-sql
"Maik" <K.Maik@web.de> wrote in message news:<9na15r$ku4$1@narses.hrz.tu-chemnitz.de>...
> Its clear, union concat the two results.
> 
> But he can also use this join version, if its the intention.
> 
> select t1.id, sum(t1.amount), t2.id, sum(t2.amount) from table1 as t1,
> table2 as t2 where t1.id=t2.id;
> 
> Ciao Maik

This is not right, i wouldnt even bather you if this was the simple
answer.

t1.id=t2.id would mean in doubled or tripled aggregation,
since t1.id and t2.id are not unique, thats why I had to aggregate
them in first Q1, Q2 querires, and link them by ID in the last one.

I don't understand what UNION got to do here. then you probably have
to make three union links of inner, left and right joined tables.

This is not that easy as it seems.
Is there a universal SQL string "expanding" rules, like in math or so?

Thanks


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

Предыдущее
От: "datactrl"
Дата:
Сообщение: array variable in pl/pgsql
Следующее
От: A_Schnabel@t-online.de (Andre Schnabel)
Дата:
Сообщение: Re: SQL request change when upgrade from 7.0.2 to 7.1.3