Re: Optimal query suggestion needed

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Optimal query suggestion needed
Дата
Msg-id 40D19E62.8090406@archonet.com
обсуждение исходный текст
Ответ на Optimal query suggestion needed  (Interzone <lists@interzone.gr>)
Ответы Re: Optimal query suggestion needed
Список pgsql-sql
Interzone wrote:
> Hi all,
> 
> I'm trying to create a view for a client, but I'm failing miserably so I 
> thought I'ld ask for some help. The initial analysis was quite 
> complicated, and that specific need never came up until recently, and 
> unfortunately, changing the tables is probably not an option :(
> 
> 
> Given the tables :
> 
> create table t0  (
>    code integer,
>    address varchar,
>    mun integer
> )
> 
> create table t1 (
>    code integer,
>    pname varchar
> );
> 
> create table t2  (
>    code integer,
>    t0_fk integer,
>    t1_fk integer,
>    avail bool
> );
> 
> 
> I want to create a view that will have:
> from table t0 the elements "code", "address" and "mun"
> from table t1 the elements "code" and "pname"
> from table t2 the total number of elements, and the total number of 
> elements where avail = true, for every value t0_fk (foreign key to t0) 
> and t1_fk (foreigh key to t1).

So there's no connection between column "code" in any of the tables? I'm 
confused as to the correlation between t0 and t1. I'm also not clear 
what t2.code is supposed to be.

Could you give a short (5 rows each) example of the contents of the 
tables and the expected results?

--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: Interzone
Дата:
Сообщение: Optimal query suggestion needed
Следующее
От: Tom Lane
Дата:
Сообщение: Re: use of a composite type in CREATE TABLE?