gcj wrote:
> I have the following three tables: CARS TRUCKS SUVS
>
> Although the tables contain numerous columns each, they each contain the
> following columns in common:
>
> Manufacturer
> Identification Number
> Color
>
> I would like to create a view that will display this common information
> as well as a column called “Type” that will indicate what kind of record
> it is – eg Car, Truck, or SUV.
create table car (manufacturer varchar, vin varchar, color varchar);
create table truck (manufacturer varchar, vin varchar, color varchar);
create table suv (manufacturer varchar, vin varchar, color varchar);
insert into car values('Toyota','TTT', 'Silver');
insert into truck values('Mack','QQQ', 'Black');
insert into suv values('Lexxus','ZZZ', 'Yellow');
create or replace view vehicle as
select 'car' as type,manufacturer,vin,color from car
union
select 'truck' as type,manufacturer,vin,color from truck
union
select 'suv' as type,manufacturer,vin,color from suv
;
select * from vehicle;
type | manufacturer | vin | color
-------+--------------+-----+--------
car | Toyota | TTT | Silver
suv | Lexxus | ZZZ | Yellow
truck | Mack | QQQ | Black