Questions tagged [table-alias]

65 questions
1
vote
1 answer

How to properly write sub querys that use math functions to compute column in the face of "Error Code 1248" Derived Tables must have their own Alises?

I being asked in exercise to calculate three values from two columns, List_price and discount_amount. partly some of my issue is that my programming instincts want to kick in hindering my ability to fully grasp what is being taught. Can someone…
Ben Madison
  • 105
  • 1
  • 7
1
vote
2 answers

How to fix Oracle Error "ORA-00933: SQL command not properly ended" with 'AS' keyword using several tables?

Oracle gives an error for the following code: SELECT actor_name, char_name FROM zActor AS zAct, zCharacter AS zChar WHERE zChar.char_num IN (SELECT COUNT(zP.char_num) AS charCount FROM zPlay AS zP, …
koder42
  • 27
  • 3
1
vote
2 answers

Subquery table-alias not being recognized in JOIN-ON/WHERE

I'm trying to lend some help to a hobbyist friend, using SQL Server experience to help with MySQL. He's working on a game database. I wrote this query for him SELECT ib.itemid, ii.realname as name, ib.stackSize, IFNULL(ah.price, '-') as…
Regular Jo
  • 5,190
  • 3
  • 25
  • 47
1
vote
3 answers

SQL - Table alias in Left Join

I am trying to write a simple SQL query with Left Join. This is the query: SELECT * FROM ( SELECT * FROM TRN_IN.COIT AS TRANSMISSIONS LEFT JOIN ( SELECT TRNNumber ,COUNT(ID) FROM TRN_IN.COIT AS TOTAL_LINES …
Yaniv Ben-Malka
  • 47
  • 3
  • 10
1
vote
1 answer

MySQL table alias does not work

So I am using 'as' command in this code select PERSONAL_ID,NAME,SURNAME,BIRTH_DATE,NUMBER_OF_ORDERS from( select PERSONAL_ID,NAME,SURNAME,BIRTH_DATE,count(CUSTOMER_ID) as NUMBER_OF_ORDERS from customer as C right join customer_hotel as CH on…
Giorgi Cercvadze
  • 403
  • 1
  • 7
  • 23
1
vote
4 answers

What does "foo" mean in this SQL Server Query?

for eg... SELECT * FROM ( SELECT RANK() OVER (ORDER BY stud_mark DESC) AS ranking, stud_id, stud_name, stud_mark FROM tbl_student ) AS foo WHERE ranking = 10 Here foo is…
John
1
vote
1 answer

what's the key word as in sql really indicate

1:here is a SQL query , which i find in the book select distinct T.branch_name from branch as T, branch as S where T.assets > S.assets and S.branch_city = 'Brooklyn' what i am confused is T and S both indicate table branch…
1
vote
1 answer

How can I give an alias to a table in Oracle?

Why can't I give an alias to a table in Oracle DB? I tried to write a statement like this one: select count(id) from users as usr where usr.dept = "SVC"; But Oracle threw me an error. I don't remember having problem when I use something like this…
Carven
  • 14,988
  • 29
  • 118
  • 161
1
vote
3 answers

Table Alias in SubSonic

How can I assign alias to tables with SubSonic 2.1? I am trying to reproduce the following query: SELECT * FROM posts P RIGHT OUTER JOIN post_meta X ON P.post_id = X.post_id RIGHT OUTER JOIN post_meta Y ON P.post_id = Y.post_id WHERE X.meta_key =…
Trav L
  • 14,732
  • 6
  • 30
  • 39
1
vote
1 answer

How to use a table alias with a Union statement in Access?

In an unpivoting operation, I would like the following: SELECT A, B, C FROM [complex joins/where clause] As DerivedTable UNION SELECT A, B, D FROM DerivedTable UNION SELECT A, B, E FROM DerivedTable ... but it complains that DerivedTable cannot be…
mchen
  • 9,808
  • 17
  • 72
  • 125
0
votes
3 answers

Super trivial postgreSQL question (alias)

This is what I did select f.visits from pls_fy2014_pupld14a pfpa as f and I got: SQL Error [42601]: ERROR: syntax error at or near "AS" This case below is working but I don't get why I cannot use 'as' select visits from pls_fy2014_pupld14a pfpa
SSW
  • 31
  • 3
0
votes
2 answers

MySQL Not unique table/alias

I looked at the answers of others having the same problem, but I can't figure out how to fix the "Not unique table/alias". SELECT m.*, u.* FROM ".TABLE_PREFIX."users_medals u LEFT JOIN ".TABLE_PREFIX."medals m ON u.medal_id = m.medal_id WHERE…
Spencer
  • 597
  • 2
  • 11
  • 19
0
votes
1 answer

How to solve this Oracle SQL issue?

select * from(select e.*,dense_rank() over(partition by dept_name order by salary desc) as Top_salaried from employee e) as B where Top_salaried <= 3; I have the above query that fetches top 3 salary from each dept above is working fine…
0
votes
1 answer

Sql multiple nested selects

As you can see, the beginning and the end of the week are selected with this code. I'm new to sql and I understand what's going on here in general, but I can't explain it in detail. For example ; (select lookupweekid-1 from lookupday where…
mert
  • 153
  • 1
  • 11
0
votes
1 answer

ORA-00933: SQL command not properly ended in oracle database

select * from ( select rating, avg(age) as avgage from sailors group by rating ) as temp where temp.avgage = ( select min(temp.avgage) from temp ); When i am trying to…
Nobody23
  • 3
  • 1