Skip to main content

Questions tagged [column-alias]

Filter by
Sorted by
Tagged with
0 votes
1 answer
30 views

Try to duplicate column= attribute1 at time=0 horizontally even on rows where time!=0 for every unique ID

Given a table such as this, I want to create a table via SQL without doing window functions id time attribute1 attribute1atFirstRecordedTimeperID 1 0 a a 1 2 b a 2 0 c c 2 4 d c I tried SELECT ...
Coo's user avatar
  • 101
3 votes
3 answers
11k views

"ERROR: column "a" does not exist" when referencing column alias

I am attempting to retrieve either a null or boolean value from a query. Here is my query: SELECT EXISTS (SELECT 1 FROM employee where add_uuid = '7e53fa47-ade3-4e94-8efd-b25f998b09c6') ...
Aamir's user avatar
  • 133
2 votes
1 answer
264 views

(postgre)SQL how to disambiguate a name that could be a column name or a table alias

In PostgreSQL anyway you can pass a table (row) alias into a function and it will pass the entire record in. But when you have a table alias x and also a column name x, when you specify f(x) it will ...
Gunther Schadow's user avatar
0 votes
1 answer
65 views

How do I add a where statement at the end of query for a column that does not have a table to reference from?

select CASE WHEN (to_char(((case when v.trip_order_start_date is null then case when v.manual_start_date is null then t.required_pickup_date else v.trip_order_start_date end else v....
zdavis30's user avatar
5 votes
1 answer
5k views

Why does an alias with a 'having' clause not exist in PostgreSQL?

I am trying to calculate distance between two coordinates and fetching some information based on a few conditions. A similar query with the 'having' clause was working in MySQL. But why is it not ...
Lokesh Pandey's user avatar