Derived Relation Syntax

  • 31/10/2023
  • SQL
No Comments

¨  Subquery in FROM clause must be given a name

🞑 Many DBMSes also require attributes to be named

SELECT customer_city, num_customers

FROM (SELECT customer_city, COUNT(*)

FROM customer GROUP BY customer_city)

AS counts (customer_city, num_customers)

WHERE num_customers > 2;

🞑 Nested query is called counts, and specifies two attributes

🞑 Syntax varies from DBMS to DBMS…

  • MySQL requires a name for derived relations, but doesn’t allow attribute names to be specified.

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

Subscribe to our newsletter!

More from our blog

See all posts
No Comments

Recent Posts