Meta
Meta

Reputation: 1860

FROM keyword not found where expected (Oracle SQL)

I am currently working on some select queries and am getting the error FROM keyword not found where expected in my last two queries, and I can;t for the life of me figure out what the problem is...

Here are my queries

SELECT Title, PubID AS 'Publisher ID', PubDate AS 'Publish Date' 
FROM Books WHERE PubID = 4 OR PubDate > '01-Jan-01' 
ORDER BY PubID ASC;

SELECT Title, (((Retail-Cost)/Cost) * 100) AS 'Markup %' 
FROM Books;

I am not sure if my math is correct in this one (retail - cost / cost * 100 is the goal).

I have been trying for probably 45 minutes on the first query before giving up and doing the last one, to only get the same error on that one.

Upvotes: 2

Views: 13999

Answers (1)

Justin Cave
Justin Cave

Reputation: 231661

Single quotes are used to surround string literals. Double quotes are used to surround identifiers. Column aliases are identifiers so you'd want to use double quotes

SELECT Title, 
       PubID AS "Publisher ID", 
       PubDate AS "Publish Date" 
  FROM Books 
 WHERE PubID = 4 
    OR PubDate > '01-Jan-01' 
 ORDER BY PubID ASC;

Upvotes: 8

Related Questions