1CREATE VIEW view_name AS
2SELECT column1, column2, ...
3FROM table_name
4WHERE condition;
1CREATE VIEW view_name AS SELECT id,category,MAX(created_at),content,title FROM table WHERE condition GROUP BY category
1CREATE VIEW sales.daily_sales
2AS
3SELECT
4 year(order_date) AS y,
5 month(order_date) AS m,
6 day(order_date) AS d,
7 p.product_id,
8 product_name,
9 quantity * i.list_price AS sales
10FROM
11 sales.orders AS o
12INNER JOIN sales.order_items AS i
13 ON o.order_id = i.order_id
14INNER JOIN production.products AS p
15 ON p.product_id = i.product_id;
16Code language: SQL (Structured Query Language) (sql)