Questions tagged [column-alias]
155 questions
0
votes
1 answer
Derby SQL calculation
I'm having a trouble to do a calculation in Derby.
The problem is the next:
Select column1, (column1 + 10) as newCol,
(column1+newCol) as newCol2 from sometable;
This throws an error saying that newCol does not exist, in the case…
0
votes
1 answer
How to change the name of the Columnheaders in a UNION statement
The Column headers in a UNION query are named as the select statement of the first query, how can I change the column headers to Entities and Errors?
The Query is:
SELECT DISTINCT '1001account' AS [1001account]
,[1001account] AS…

shirbaz
- 15
- 4
0
votes
2 answers
Date functions in SQL Server
Task: display the customer names and their orders happened in Pune and Kolkata locations during March month
Customers:
CUST_ID CUST_NAME LOCATION
---------------------------------
1 A HYD
2 B PUNE
3 …

Bhanu
- 1
- 1
0
votes
1 answer
The table aliases does not return results
I'm working on a practice problem and trying to use the table alias in the ON field but it's not working.
SELECT c.code AS country_code, name, year, inflation_rate
FROM countries AS c
Join to economies (alias e)
INNER JOIN economies AS e
**ON…

LenaLD
- 85
- 2
- 11
0
votes
1 answer
How to use the keyword after AS in WHERE
I am calculating the total year that a member have been registered.
I need to return the result how many member registered more than 5 years but I am having error when I run the code.
It shows "duration" invalid identifier in line 3
select…

10IEI
- 21
- 1
- 5
0
votes
0 answers
Postgresql column does not exist
I keep getting this the error below when I run the Postgresql code below that. Can anyone please point me in a direction to understand why this is happening?
Error: [Pivotal][Greenplum JDBC Driver][Greenplum]column "vin8" does not exist.
SQLState:…

rsajdak
- 93
- 12
0
votes
1 answer
Retyping alias column in mysql query
I am trying to convert some data from old tables to a new structure, where I need to convert a single key ID to composite one, amd it is giving me some trouble:
My table (simplified):
CREATE TABLE `tmplt_spoergsmaal` (
`SpID` int(10) unsigned NOT…

JoSSte
- 2,953
- 6
- 34
- 54
0
votes
2 answers
Why is my column alias not working in subquery?
I am trying to run below code on Snowflake:
SELECT
agg_zone_delivery_metrics_hourly.zone_code,
agg_zone_delivery_metrics_hourly.start_of_period_local_date,
MIN(CASE WHEN azdmh.start_of_period_local_hour_of_day = '18' THEN…

Tushar Agarwal
- 11
- 1
- 7
0
votes
1 answer
Creating a new attribute in Oracle database from two other attributes
I have a Classes table which is as follows:
Classes(classid, dept_code, course#, sect#, year, semester, limit, class_size, room, TA_B#)
The qeustion is:
Find the classid, dept_code and course# of each undergraduate class (i.e., course# < 500) that…

Vagabond
- 521
- 1
- 5
- 12
0
votes
2 answers
Mysql Select statement
I am querying a database as:
SELECT SUM(Hours)
from User
where surname = 'johnson';
Whenever I run it, as you know it will show selected Column with the name SUM(Hours).
Question:
Is there any way that I can "rename" it without altering the…

7dr3am7
- 755
- 1
- 8
- 21
0
votes
1 answer
Using parameters from select statement inside case statement
I have the following query
SELECT product.*,
(SELECT bid FROM server1 WHERE product_id = product.id) AS bid1,
(SELECT bid FROM server2 WHERE product_id = product.id) AS bid2,
CASE
WHEN bid1 > bid2 THEN '1 wins'
WHEN bid2 > bid1 THEN '2…

pewpewlasers
- 3,025
- 4
- 31
- 58
0
votes
0 answers
postgres second defined column returns false
I am trying to define multiple columns in a SELECT statement,
the problem is I keep getting the column "col_name" does not exist error when I try to define a second column name with as for a calculation.
this is my query:
SELECT fa.farmer_id as…

Dror Bogin
- 453
- 4
- 13
0
votes
3 answers
Cannot use alias from SELECT clause in the WHERE clause
USE stormtrooper_java;
SELECT imperial_battlegroup.BGID, imperial_battlegroup.Designation, imperial_battlegroup.HQ_LocationX, imperial_battlegroup.HQ_LocationY,
stormtrooper_unit.STUID, stormtrooper_unit.UnitCmd, stormtrooper_unit.UnitType,…

Mohammad Alamri
- 27
- 6
0
votes
1 answer
Column "date_norm" does not exist in Postgresql
I'm going to port my data from sqlite3 to PostgreSQL (version 10.1) but some query statements look like not compatible with the originals. for example, the statement:
SELECT date+300 AS date_norm, close FROM History WHERE date_norm>1502681700;
when…

lzwujun
- 1
0
votes
1 answer
alias table with union all not works
I have ora-00094 (identifier not valid) in a simple query but I can't see why. Could you help me please?
select columnA, 'More than 4000 bytes'
from tableA
union all
select p.columnB, listagg(p.columnC, ',') within group (order by p.columnC)
from…

user8957934
- 53
- 6