Search Postgresql Archives

Same column names in a subresult table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux