0 votes
1 view
in SQL by (20.3k points)

Why doesn't the following work?

SELECT name FROM (SELECT name FROM agentinformation)

I guess my understanding of SQL is wrong because I would have thought this would return the same thing as

SELECT name FROM agentinformation

Doesn't the inner select statement create a result set which the outer SELECT statement then queries?

1 Answer

0 votes
by (40.4k points)

You should use the alias in the subquery like this:

SELECT ID FROM (SELECT ID FROM agent_information) s  

Or

More explicitly you can use this way:

SELECT s.ID FROM (SELECT ID FROM agent_information) s  

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...