CREATE TABLE CUSTOMER (
    CUST_ID INT (3) PRIMARY KEY,
    FIRST_NAME VARCHAR (10),
    LAST_NAME VARCHAR (10),
    ADDRESS CHAR (25),
    CITY VARCHAR (10),
    STATE CHAR(2),
    POSTAL INT(5),
    EMAIL VARCHAR (30),
    BALANCE DECIMAL (5,2),
    CREDIT_LIMIT DECIMAL (6,2),
    REP_ID INT (2)
);
INSERT INTO CUSTOMER VALUES
    ( 126, 'Joey', 'Smith', '17 Fourth St', 'Cody', 'WY', '82414',
    'jsmith17@example.com', 80.68, 500.00, 05 ),
    (182, 'Billy', 'Rufton', '21 Simple Cir', 'Garland', 'WY', '82435', 
    'billyruff@example.com', 43.13, 750.00, 10),
    (227, 'Sandra', 'Pincher', '53 Verde Ln', 'Powell', 'WY', '82440', 
    'spinch2@example.com', 156.38, 500.00, 15),
    (294,'Samantha', 'Smith', '14 Rock Ln', 'Ralston', 'WY', '82440', 
    'ssmith5@example.com', 58.60, 500.00, 10),
    (314, 'Tom', 'Rascal', '1 Rascal Farm Rd', 'Cody', 'WY', '82414', 
    'trascal3@example.com', 17.25, 250.00, 15),
    (375, 'Melanie', 'Jackson', '42 Blackwater Way', 'Elk Butte', 'WY', '82433', 
    'mjackson5@example.com', 252.25, 250.00, 05),
    (435, 'James', 'Gonzalez', '16 Rockway Rd', 'Wapiti', 'WY', '82450', 
    'jgonzo@example.com', 230.40, 1000.00, 15),
    (492, 'Elmer', 'Jackson', '22 Jackson Farm Rd', 'Garland', 'WY', '82435', 
    'ejackson4@example.com', 45.20, 500.00, 10),
    (543, 'Angie', 'Hendricks', '27 Locklear Ln', 'Powell', 'WY', '82440', 
    'ahendricks7@example.com', 315.00, 750.00, 05),
    (616, 'Sally', 'Cruz', '199 18th Ave', 'Ralston', 'WY', '82440', 
    'scruz5@example.com', 8.33, 500.00, 15),
    (721, 'Leslie', 'Smith', '123 Sheepland Rd', 'Elk Butte', 'WY', '82433', 
    'lsmith12@example.com', 166.65, 1000.00, 10),
    (795, 'Randy', 'Blacksmith', '75 Stream Rd', 'Cody', 'WY', '82414', 
    'rblacksmith6@example.com', 61.50, 500.00, 05);
-- List the sum of the balances of all customers for each sales rep but
-- restrict the output to those sales reps for which the sum is more than $150. 
-- Order the results by sales rep ID.
SELECT REP_ID, SUM(BALANCE) FROM CUSTOMER
GROUP BY REP_ID HAVING SUM(BALANCE)>150
ORDER BY REP_ID

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: