Question: Need the SQL query to solve: For all sales staff who earned at least $50 in commission for the month, list the salespersons id, name,

Need the SQL query to solve:

For all sales staff who earned at least $50 in commission for the month, list the salespersons id, name, commission earned and the percentage of the chains total commission. (Round the percent to the nearest tenth of a percent.) Display the listing starting with the best salesperson (most commission earned).

Company Background:

For each of its stores, our company keeps track of the store's ID (C2), name (C 15), state (C2), size in square feet (D4, 0), region code (C1) and region name (C9), monthly rent (D4, 0), the percent of sales that are paid by credit card (D4, 0), and the IDs (C2), names (C20) and commission percentages (D2, 0) of all the salespeople working at the store. Each salesperson can work at only one of our stores. In addition, our company keeps track of the store type (C2) and general description of the story type (C12); i.e. mall store or strip center store.

For each piece of clothing that our company sells in its stores, we keep track of the style number (C6), the name (C10) and address (C 15) of the vendor who supplies the style to our company and the cost of the style -- what we paid the vendor per garment (D5, 2). In addition, each piece of clothing is assigned a specific department -- size ranges like infants, toddlers, etc. (C12), a description (C20), and a retail price. We frequently buys the same style in multiple colors. Our company also tracks the style's gross profit margin -- the difference between retail and cost divided by retail (D5,2). Each style is supplied by only one vendor, but a vendor may supply several different styles. Each store does not necessarily sell every style - regional differences in sales patterns dictate different stores carry different mixes of styles.

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)

salesid (FK) varchar(2)

numsold integer(2)

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!