Same column names in a subresult table - Mailing list pgsql-general

From Durumdara
Subject Same column names in a subresult table
Date
Msg-id CAEcMXhkvRDM3eGqgA4jH6TCE3gELYTeRP+72nWYG2KUwxb-MQQ@mail.gmail.com
Whole thread Raw
Responses Re: Same column names in a subresult table
Re: Same column names in a subresult table
List 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 by date:

Previous
From: Ron
Date:
Subject: Re: Question about integer out of range in function
Next
From: Rory Campbell-Lange
Date:
Subject: Re: Same column names in a subresult table