column-alias

Creating a new attribute in Oracle database from two other attributes

时光毁灭记忆、已成空白 提交于 2021-02-11 12:36:25
问题 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 was offered in Spring 2017. For each such class, also list the number of seats available (computed by limit – class_size) under the header “seats_available”. I tried this simple approach: select classes.classid, classes.dept_code, classes.course#,

column does not exist error even when using the 'as' keyword [duplicate]

二次信任 提交于 2021-01-28 03:53:44
问题 This question already has answers here : Using an Alias column in the where clause in Postgresql (6 answers) Column doesn't exist? (1 answer) Closed 1 year ago . I get this error: ERROR: column "errors" does not exist LINE 11: where errors >= 1 even that i checked the result with select. I'm using postgresql server, i have a table named log like the following: Column | Type | Modifiers --------+--------------------------+-------------------------------------------------- path | text | ip |

Using alias name in WHERE clause

☆樱花仙子☆ 提交于 2020-01-09 11:55:11
问题 I am executing the below query and using alias name for all columns. I have named alias with a . since that is a requirement. now, I want to refer to the alias name directly in the where clause and i do is as given below: SELECT pt.prod_desc AS"PROD_DESC", ( CASE WHEN pt.prod_level='2' THEN 'Product' WHEN pt.prod_level='4' THEN 'Sub-Product' WHEN pt.prod_level='5' THEN 'Service' ELSE 'N/A' END) AS"PROD_LEVEL", prod_id AS "PROD_ID", isactive AS "IsActive", updt_usr_sid AS "UPDT_USR_SID", updt

Oracle rename columns from select automatically?

跟風遠走 提交于 2019-12-31 00:58:05
问题 I have 2 tables with the following fields. Table1 AA BB CC DD Table2 AA CC EE Query Select t1.*, t2.* from table1 t1, join table2 t2 on table1.DD = table2.EE My data columns back with the following column names: AA, BB, CC, DD, **AA_1**, **CC_1**, EE I don't want the column names like that. I want them to have the table name prefixed in the names of common (or all columns). I could fix this with: select t1.AA as t1_AA, t1.BB as t1_BB, t1.CC as t1_CC, t1.DD as t1_DD, t2.AA as t2_AA, t2.CC as

SQL not recognizing column alias in where clause

本小妞迷上赌 提交于 2019-12-17 13:07:14
问题 I am only a beginner in SQL, but I've come across this annoying error. SQL is having an issue with the WHERE clause of this script: SELECT ITEM_ID, ITEM_PRICE, DISCOUNT_AMOUNT, QUANTITY, (ITEM_PRICE*QUANTITY) AS price_total, (DISCOUNT_AMOUNT*QUANTITY) AS discount_total, ((ITEM_PRICE-DISCOUNT_AMOUNT)*QUANTITY) AS item_total FROM ORDER_ITEMS WHERE item_total > 500 ORDER BY item_total; I am receiving this error: Error starting at line : 1 in command - SELECT ITEM_ID, ITEM_PRICE, DISCOUNT_AMOUNT,

SQL not recognizing column alias in where clause

本秂侑毒 提交于 2019-12-17 13:05:07
问题 I am only a beginner in SQL, but I've come across this annoying error. SQL is having an issue with the WHERE clause of this script: SELECT ITEM_ID, ITEM_PRICE, DISCOUNT_AMOUNT, QUANTITY, (ITEM_PRICE*QUANTITY) AS price_total, (DISCOUNT_AMOUNT*QUANTITY) AS discount_total, ((ITEM_PRICE-DISCOUNT_AMOUNT)*QUANTITY) AS item_total FROM ORDER_ITEMS WHERE item_total > 500 ORDER BY item_total; I am receiving this error: Error starting at line : 1 in command - SELECT ITEM_ID, ITEM_PRICE, DISCOUNT_AMOUNT,

Why can't I use column aliases in the next SELECT expression?

风格不统一 提交于 2019-12-17 07:52:25
问题 Can I modify the next to use the column aliases avg_time and cnt in an expression ROUND(avg_time * cnt, 2) ? SELECT COALESCE(ROUND(stddev_samp(time), 2), 0) as stddev_time, MAX(time) as max_time, ROUND(AVG(time), 2) as avg_time, MIN(time) as min_time, COUNT(path) as cnt, ROUND(avg_time * cnt, 2) as slowdown, path FROM loadtime GROUP BY path ORDER BY avg_time DESC LIMIT 10; It raises the next error: ERROR: column "avg_time" does not exist LINE 7: ROUND(avg_time * cnt, 2) as slowdown, path The