ora 923You are missing the comma between them. Which is why Oracle believes the word FROM was missing at the end of the third . Fix this andORA-00923: FROM keyword not found where expected Below is the SQL : SELECT A.Agent_key, Sum(Total_Orders) FROM (SELECT A.Agent_key, Sum(Total_Orders)