Question: SQL Query to return: For each salesperson, list the sales ID, name, total dollar sales for the first month (weeks 1 - 4), and the

SQL Query to return:

For each salesperson, list the sales ID, name, total dollar sales for the first month (weeks 1 - 4), and the total commission earned by the salesperson. Sort the listing in order from highest to lowest monthly sales.

Based on Tables:

Style

Styleno (PK) varchar(6) not null,

vendorid (FK) varchar(3),

deptid (FK) varchar(2),

sdesc varchar(20),

cost DECIMAL(5,2),

retail DECIMAL(5,2)

Region

Regioncode (PK) varchar(2) not null,

rdesc varchar(9)

Store

storeid (PK) varchar(2) not null,

storename varchar(15),

state varchar(2),

typecode (FK) varchar(1),

rent integer(4),

pctcredit integer(4),

regioncode (FK) varchar(2),

storesize integer(4));

Salesperson

Salesid (PK) varchar(2) not null,

sname varchar(20)

storeid varchar(2)

commission integer(2)

Typecode

typecode (PK) varchar(1) not null

typedesc varchar(12)

Vendor

vendorid (PK) varchar(3) not null

vname varchar(10)

vaddress varchar(15)

Department

deptid (PK) varchar(2) not null

deptname varchar(12)

Sale

weekno integer(1)

styleno (FK) varchar(6)

saleid (FK) varchar(2)

numsold integer(2)

Please let me know in the future if it is better to provide SQL code to create actual tables as some of the answers I have been getting are returning errors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!