Same column names in a subresult table

Поиск
Список
Период
Сортировка
От Durumdara
Тема Same column names in a subresult table
Дата
Msg-id CAEcMXhkvRDM3eGqgA4jH6TCE3gELYTeRP+72nWYG2KUwxb-MQQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Same column names in a subresult table  (Rory Campbell-Lange <rory@campbell-lange.net>)
Re: Same column names in a subresult table  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
Hello!


I have a big "WITH QUERY", with many subqueries.

I have a date field, named "XDate".

In the middle I duplicated this field:

...
midqry1 as (
  select coalesce(XDate , '0001-01-01'), * from prevqry
),
midqry2 as (
  select ArtID, max(XDate) as Max_XDate from midqry1
  where acq = True
  group by ArtID
)
...

Result: ERROR: column reference "XDate" is ambiguous


As I remember, InterBase simply renamed the second XDate to XDate_1 or XDate1.
But as I see the PGSQL keeps the first and second too (which comes with an asterisk "*").

So in midqry1 I have two XDate columns.

If the two XDates came from different tables, I can use the table prefix.

But now they are in one table.

Is there any way to suppress the original field?

Or say to PGSQL to skip the first XDate field?

Like select t.* (EXCEPT XDate) from t

Or can I reference them by the order?

Ok, I can solve this problem by renaming the new first XDate, but I want to know is there any solution to this problem?

Thank you for any help, info, example!

Best regards
   dd



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

Предыдущее
От: Ron
Дата:
Сообщение: Re: Question about integer out of range in function
Следующее
От: Rory Campbell-Lange
Дата:
Сообщение: Re: Same column names in a subresult table