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

--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

Leave a comment