Skip to content
Advertisements

SQL Drived Table

A derived table is a table expression that appears in the FROM clause of a query. You can apply derived tables when the use of column aliases is not possible because another clause is processed by the SQL translator before the alias name is known.

Rules:

  • All columns in the query to be used for “Derived table” must be named.
  • Column names must be unique.
  • If “ball” is used in the query to be used for the “drive” table, the order cannot be sorted by “order by”.
--DRIVED TABLE

SELECT * 
FROM BikeStores.sales.customers as cus
SQL Drived Table

--DRIVED TABLE

SELECT DISTINCT *
FROM BikeStores.sales.customers as cus
INNER JOIN(
	SELECT DISTINCT *
	FROM BikeStores.sales.orders as ord
	WHERE ord.customer_id < 11
) data
ON cus.customer_id = data.customer_id
SQL Drived Table
SQL Drived Table
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: