1
2
3
4
5 CREATE VIEW customer_master AS
6 SELECT cu.customer_id AS id,
7 cu.first_name || ' ' || cu.last_name AS name,
8 a.address,
9 a.postal_code AS "zip code",
10 a.phone,
11 city.city,
12 country.country,
13 CASE
14 WHEN cu.activebool THEN 'active'
15 ELSE ''
16 END AS notes,
17 cu.store_id AS sid
18 FROM customer cu
19 INNER JOIN address a USING (address_id)
20 INNER JOIN city USING (city_id)
21 INNER JOIN country USING (country_id);
1
2
3
4
5 CREATE VIEW customer_master AS
6 SELECT cu.customer_id AS id,
7 cu.first_name || ' ' || cu.last_name AS name,
8 a.address,
9 a.postal_code AS "zip code",
10 a.phone,
11 city.city,
12 country.country,
13 CASE
14 WHEN cu.activebool THEN 'active'
15 ELSE ''
16 END AS notes,
17 cu.store_id AS sid,
18 cu.email
19 FROM customer cu
20 INNER JOIN address a USING (address_id)
21 INNER JOIN city USING (city_id)
22 INNER JOIN country USING (country_id);
1CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW name [ ( column_name [, ...] ) ]
2 [ WITH ( view_option_name [= view_option_value] [, ... ] ) ]
3 AS query
4