Questions tagged [column-alias]
5 questions
5
votes
1 answer
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 working in PostgreSQL?
This is my query:
SELECT…
Lokesh Pandey
- 197
- 3
- 10
3
votes
3 answers
"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') AS a,
CASE WHEN a = false then null
…
Aamir
- 133
- 1
- 1
- 4
2
votes
1 answer
(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 not know which one, throw error "ambiguous name x"…
Gunther Schadow
- 523
- 4
- 10
0
votes
1 answer
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
t1.id,
t1.time,
…
Coo
- 101
- 5
0
votes
1 answer
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.trip_order_start_date end + (interval '-1 hours' * ofc.offset)) at…
zdavis30
- 1
- 1