Questions tagged [column-alias]

155 questions
0
votes
3 answers

Alias creation in SQL Server

How we can create alias of a column in table in SQL Server?
ram singh
  • 1
  • 4
0
votes
1 answer

How to use a column alias immediately after it's been named in a SELECT clause?

I created a column alias in line 7 called total_city_pop. Then, in line 8, I tried to use that alias in a new calculation. But, I received an error message that says "column "total_city_pop" does not exist LINE 8: (ci.city_proper_pop +…
Sebastian
  • 957
  • 3
  • 15
  • 27
0
votes
1 answer

Unable to give an alias name to a column using "as" in mysql

Query: Select batch as Senior_PM_Batch from profile where designation = 'project manager' and batch <= ALL(select batch from profile where designation = 'project manager'); The query gives the accurate result but is not able to rename the column…
0
votes
2 answers

Postgres SQL - Column does not exist

SELECT nmemail as order_email, dtorder, vlOrder, cohorts.cohortdate FROM factorderline JOIN (SELECT nmemail as cohort_email, Min(dtorder) AS cohortDate FROM factorderline GROUP BY cohort_email limit 5) cohorts…
p.magalhaes
  • 7,595
  • 10
  • 53
  • 108
0
votes
0 answers

Mysterious error when combining lead function, second window function and column alias

Consider the following query: select corpus_date as alias ,lead(word, 1) over (partition by corpus order by word_count desc) lead ,max(word_count) over (partition by corpus) max_word_count from [publicdata:samples.shakespeare] where…
oulenz
  • 1,199
  • 1
  • 15
  • 24
0
votes
3 answers

H2 select expression column alias

There is H2 table: CREATE TABLE IF NOT EXISTS sometable (ondate DATE NOT NULL); With data INSERT INTO sometable VALUES ('2015-07-07'); INSERT INTO sometable VALUES ('2014-07-07'); INSERT INTO sometable VALUES ('2013-07-07'); I want to limit the…
0
votes
1 answer

MySQL how to reuse select column aliase, when I aliase subquery?

I have something like: Select1 ... ,(fieldA - fieldB) AS Y, ,(Select2 (Select3 percent From ... Join.... Where ... Order by…
przemo_li
  • 3,932
  • 4
  • 35
  • 60
0
votes
0 answers

Creating MYSQL column (Alias) based on the value of that column

I have the following tables Products, Prices, stores (Suppliers) and Country Products table: ProductID, ProductName Stores Table: StoreID, StoreName, Country (country name of the supplier) Price Table: PriceID, Date, Price, StoreID,…
0
votes
2 answers

Column alias error with SQL Server UDF

I'm trying to make a stored sql server function that will return a table of median values that I can join back to another table, thusly: CREATE FUNCTION [dbo].getmedian (@varPartionBy1 int,@varPartionBy2 int, @varForTieBreak int, @varForMeasure…
ouonomos
  • 700
  • 1
  • 9
  • 25
0
votes
2 answers

MySQL select statement with alias fails with column not found

Development Environment Reference: Fedora FC18 Tomcat Server 7.0.39 (localhost config) Eclipse Juno Release 2 Mysql-connecor-java Ver. 5.1.26 (jar) Mysql-server Ver. 5.5.32 (jar) The following select statement fails with "column 'depth' not…
user2766845
  • 1
  • 1
  • 3
-1
votes
1 answer

ORA-00998: "must name this expression with a column alias"

I need help with that error this is my code CREATE OR REPLACE VIEW emplpersuc AS SELECT SUCURSAL.NOMBRE, COUNT(SUCURSAL.NOMBRE) FROM VENTA JOIN SUCURSAL ON SUCURSAL_CODIGO_SUCURSAL=CODIGO_SUCURSAL GROUP BY SUCURSAL.NOMBRE ORDER BY…
-1
votes
2 answers

Creating a column in SELECT and then filtering it with WHERE (PostgreSQL)

I'm trying to compute the difference between two columns, and then filter the results within a WHERE command. Like this: SELECT abs("c1" - "c2") as diff FROM table1 WHERE diff < 3 I get a "ERROR: column "diff" does not exist". How should I…
Lucien S.
  • 5,123
  • 10
  • 52
  • 88
-1
votes
2 answers

In SQL, why can't I use the other queries in SELECT statement to do calculation?

Here's the sample table 'test0608': product_name color amount Product1 Red 123 Product1 Blue 126 Product2 Blue 103 Product2 Red NULL Product2 Red …
-1
votes
1 answer

When was aliasing using "=" versus "as" introduced and what is the name of that version

When is the name of the flavor of sql that supports "=" for alias instead of using "as"? SELECT A = Col1 ,B = Col2 FROM Table as opposed to SQL-86 SELECT Col1 AS A , Col2 AS B FROM Table
e-Fungus
  • 321
  • 3
  • 17
-1
votes
1 answer

How to order by specific value first in Redshift ORDER BY clause?

Amazon Redshift 1.0.22169 I'm trying to order by company names and place any "N/A" values first. I have a simple test table like so: +----+-----------+ | id | name | +----+-----------+ | 1 | Company 3 | | 2 | Company 1 | | 3 | N/A | | …
1 2 3
10
11