the bu
find this sql command for my
– Find the top 2 brands by dollar-amount sold in the past year.
– Find the top 2 brands by unit sales in the past year.
– Show sales trends for various brands over the past 3 years, by year, month, week.
Then break these data out by gender of the buyer and then by income range.
– Find the number of models in different body styles (group by number of door, etc.)
database:
create table Brand
(id int not null primary key,
name varchar(50) not null)
create table Model
(id int not null primary key,
number_doors int not null,
number_wheels int not null,
vehicle_type char(50) not null,
engine_capacity int not null,
brandid int foreign key references Brand (id))
create table Choice
(id int not null primary key,
color char(10),
engine_type char(20))
create table Model_Option
(modelid int foreign key references Model (id),
optionid int foreign key references Choice (id),
primary key (modelid, optionid))
create table Vehicle
(vin int not null primary key,
modelid int foreign key references Model (id),
makeid int foreign key references Brand (id),
optionid int foreign key references Choice (id))
create table Dealer
(id int not null primary key,
location char(50) not null)
create table Dealer_Model
(dealerid int foreign key references Dealer (id),
modelid int foreign key references Model (id))
create table Customer
(id int not null primary key,
address varchar(100) not null,
phone char(20),
gender char(5),
annual_income int)
create table Sales
(id int not null primary key,
customerid int foreign key references Customer (id),
vehicleid int foreign key references Vehicle (vin),
dealerid int foreign key references Dealer (id))
create table Supplier
(id int not null primary key,
location char(50) not null)
create table Supplier_Model
(supplier_id int foreign key references Supplier (id),
modelid int foreign key references Model (id))



Step by step
Solved in 2 steps with 1 images









