Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Explanation for the following SQL query

I came across this SQL query and am not able to understand how is it working.

SELECT answer AS answer
FROM
  (SELECT answer
   FROM "default"."enriched-responses-dev") AS virtual_table
LIMIT 1000;

And how is it different from this?

SELECT answer AS answer
FROM "default"."enriched-responses-dev"
LIMIT 1000;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I think the second SQL statement is more efficient because there is no need for a temporary result. As far as the output is concerned, both will return the same result.

There is no need for a sub-query in this instance.

It can be simplified to:

SELECT answer
FROM "default"."enriched-responses-dev"
LIMIT 1000;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading