You are on page 1of 6

1. Show the ages and salaries of all salespeople. SELECT AGE, SALARY FROM TBLSALESPERSON; 2.

Show the ages and salaries of all salespeople but omit duplicates. SELECT DISTINCT AGE, SALARY FROM TBLSALESPERSON; 3. Show the names of salespeople under 30 years old. SELECT NAME FROM TBLSALESPERSON WHERE AGE < 30; 4. Show the names of all salespeople who have an order with Abernathy Constructi on. SELECT TBLSALESPERSON.NAME FROM (TBLSALESPERSON INNER JOIN TBLORDER ON TBLSALESPERSON.NAME = TBLORDER.SALESPERSONNAME) WHERE TBLORDER.CUSTNAME = 'ABERNATHY CONSTRUCTION'; 5. Show the names of all salespeople who earn more than $49,999 and less than $1 00,000. SELECT NAME FROM TBLSALESPERSON WHERE SALARY < 100000 AND SALARY > 49999; 6. Show the names of all salespeople in their fifties. Use the between keyword. SELECT NAME FROM TBLSALESPERSON WHERE AGE BETWEEN 50 AND 59; 7. Show the names of all salespeople in their fifties. Use the like keyword. SELECT NAME FROM TBLSALESPERSON WHERE CSTR(AGE) LIKE '5?'; 8. Show the names of customers which are located in a city ending with S. SELECT NAME FROM TBLCUSTOMER WHERE RIGHT$(CITY,1) = 'S'; 9. Show the names and salary of all salespeople who do not have an order with Ab ernathy Construction, in ascending order of salary.

(SELECT MAX(AGE) AS OLDEST FROM TBLSALESPERSON) WHERE AGE=OLDEST. Show the name of the oldest salesperson. .SALESPERSONNAME) ORDER BY SALARY. SELECT NAME FROM TBLSALESPERSON. 13. 10.OLDEST. SELECT NAME FROM TBLSALESPERSON. Compute the number of different customers who have an order.SELECT TBLSALESPERSON. Compute the average age of a salesperson. SELECT Count(NUMBER) AS COUNT_OF_ORDERS FROM TBLORDER. (SELECT MAX(AGE) AS OLDEST FROM TBLSALESPERSON) AS OLD_PEOPLE WHERE AGE=OLD_PEOPLE. 12.OLDEST. (SELECT MAX(AGE) AS OLDEST FROM TBLSALESPERSON) AS OLD_PEOPLE WHERE TBLSALESPERSON. SELECT AVG(AGE) AS AVERAGE_AGE FROM TBLSALESPERSON. 11. SALARY FROM TBLSALESPERSON WHERE NOT EXISTS (SELECT * FROM TBLORDER WHERE TBLORDER. (SELECT MAX(AGE) AS OLDEST FROM TBLSALESPERSON AS OLD_PEOPLE) WHERE AGE=OLDEST.CUSTNAME = 'ABERNATHY CONSTRUCTION' AND TBLSALESPERSON.NAME. SELECT NAME FROM TBLSALESPERSON.NAME = TBLORDER. SELECT COUNT(CUSTNAME) AS NUM_CUST_WITH_ORDERS FROM (SELECT DISTINCT CUSTNAME FROM TBLORDER).AGE=OLD_PEOPLE. Compute the number of orders. SELECT NAME FROM TBLSALESPERSON.

SELECT TBLSALESPERSON.NAME. Compute the number of orders for each salesperson.NAME = TBLORDER.SALESPE RSONNAME GROUP BY TBLSALESPERSON. Show the ages of all salespeople who have an order with a customer in Memphi s (use a subquery).NAME = TBLORDER. COUNT(SALESPERSONNAME) AS NUMBER_OF_ORDERS_OVER_500 FROM TBLORDER HAVING AMOUNT > 500 GROUP BY SALESPERSONNAME.14.SALESPERSONNAME AND EXISTS (SELECT * FROM TBLCUSTOMER . AGE FROM TBLSALESPERSON INNER JOIN TBLORDER ON TBLSALESPERSON. SELECT AGE FROM TBLSALESPERSON WHERE EXISTS (SELECT * FROM TBLORDER WHERE TBLSALESPERSON.NAME = TBLORDER. COUNT(SALESPERSONNAME) AS NUMBER_OF_ORDERS FROM TBLORDER GROUP BY SALESPERSONNAME.CUSTNAME = 'ABERNATHY CONSTRUCTION' AND TBLSALESPERSON.SALESP ERSONNAME WHERE TBLORDER. Show the names and ages of salespeople who have an order with Abernathy Cons truction.NAME. SELECT SALESPERSONNAME.CUSTNAME = 'ABERNATHY CONSTRUCTION' ORDER BY AGE DESC. SELECT TBLSALESPERSON. Show the names and ages of salespeople who have an order with Abernathy Cons truction.NAME.SALESPERSONNAME) ORDER BY AGE DESC. 15. in descending order of age (use a join). Compute the number of orders for each salesperson. COUNT(TBLORDER. AGE FROM TBLSALESPERSON WHERE EXISTS (SELECT * FROM TBLORDER WHERE TBLORDER.NAME = TBLORDER. 16. 18. SELECT SALESPERSONNAME.SALESPERSONNAME) AS COUNT_OF_ORDERS FROM TBLSALESPERSON LEFT JOIN TBLORDER ON TBLSALESPERSON. SELECT TBLSALESPERSON. 17.NAME. in descending order of age (use a subquery). considering only orders f or an amount exceeding 500.

TBLSALESPERSON. 19. 24. 23.SALESP ERSONNAME GROUP BY TBLSALESPERSON. Show the names and ages of salespeople who have an order with all customers.NAME.NAME = TBLORDER.WHERE TBLORDER. (use a left or right join).NAME) ON TBLSALESPERSON.SALESPE RSONNAME. .NAME.NAME = TBLORDER.CUSTNAME WHERE TBLCUSTOMER.NAME = TBLORDER. SELECT DISTINCT TBLSALESPERSON.SALESPERSONNAME) > 1.NAME.NAME AND TBLCUSTOMER. 20. TBLSALESPERSON.CUSTNAME) ON TBLSALESPERSON.SALESPERSONNAME = TBLSALESPERSON. SELECT TBLSALESPERSON. 21.NAME.AGE HAVING COUNT(TBLSALESPERSON. Show the names of salespeople who have two or more orders.N AME = TBLORDER. SELECT TBLSALESPERSON.NAME = TBLORDER. Show the names of salespeople along with the names of the customers which ha ve ordered from them.AGE FROM TBLCUSTOMER INNER JOIN (TBLORDER INNER JOIN TBLSALESPERSON ON TBLORDER.NAME = TBLORDER.NAME) ON TBLCUSTOMER. 22.CUSTNAME = TBLCUSTOMER.CUSTNAME FROM TBLSALESPERSON LEFT JOIN TBLORDER ON TBLSALESPERSON. SELECT SALESPERSONNAME FROM TBLORDER GROUP BY SALESPERSONNAME HAVING COUNT(SALESPERSONNAME) > 1. AGE HAVING COUNT(TBLORDER. Show the industry type and ages of the salespeople of all orders for compani es in Memphis.SALESPERSONNAME WHERE TBLCUSTOMER.NAME) FROM TBLCUSTOMER).NAME)=(SELECT COUNT (TBLCUSTOMER.CITY = 'MEMPHIS'. Include salespeople who have had no orders. Show the names and ages of salespeople who have two or more orders.CITY = 'MEMPHIS'. SELECT AGE FROM TBLSALESPERSON INNER JOIN (TBLORDER INNER JOIN TBLCUSTOMER ON TBLORDER. AGE FROM TBLSALESPERSON INNER JOIN TBLORDER ON TBLSALESPERSON. SELECT INDUSTRYTYPE.CITY = 'MEMPHIS' )).SALESPERSONNAME GROUP BY TBLSALESPERSON. TBLORDER.AGE FROM TBLSALESPERSON INNER JOIN (TBLCUSTOMER INNER JOIN TBLORDER ON TBLCUSTOMER.CUST NAME = TBLCUSTOMER.NAME. Show the ages of all salespeople who have an order with a customer in Memphi s (use a join).

Insert rows into a new table. Include the fields name a nd age.000. To be in the new table. Use Make Table query RestoreSalesPerson to restore from backup copy of tblSalesPersonBackup called tblSalesPersonBackup INSERT INTO TBLSALESPERSON (NAME. AGE INTO TBLHIGHACHIEVERS FROM TBLSALESPERSON WHERE SALARY > 100000. Give all salespeople a 10 percent pay increase. CITY) VALUES ( "X". a salesperson must have a salary of at least 100 .25. Insert a new name and age into tblsalesperson assume that salary is not determined.000. "YPSILANTi"). 31. SELECT NAME. Use Make Table query Resto reOrder to restore from backup copy of tblOrder called tblOrderBackup DELETE * FROM TBLORDER WHERE CUSTNAME = 'ABERNATHY CONSTRUCTION'. 32. 26. "7"). Use Make Table query Res toreSalesPerson to restore from backup copy of tblSalesPersonBackup called tblSa lesPersonBackup UPDATE TBLSALESPERSON SET SALARY = SALARY*1.10. tblhighachiever. 30. AGE) VALUES ( "Lucy". Insert a new row into tblcustomer. INDUSTRYTYPE. 28. 27. Change the salary of salesperson Jones to 45. "A". Use Make Table query RestoreCust omer to restore from backup copy of tblCustomer called tblCustomerBackup DELETE * FROM TBLCUSTOMER WHERE NAME = 'ABERNATHY CONSTRUCTION'. Delete all orders for Abernathy Construction. Use Make Table query RestoreSa lesPerson to restore from backup copy of tblSalesPersonBackup called tblSalesPer . Use Make Table query RestoreCustomer to restore from backup copy of tblCustomer called tblCustomerBackup INSERT INTO TBLCUSTOMER (NAME. Delete customer Abernathy Construction. Use Make Table query R estoreSalesPerson to restore from backup copy of tblSalesPersonBackup called tbl SalesPersonBackup UPDATE TBLSALESPERSON SET SALARY=45000 WHERE NAME = 'JONES'. Change salesperson Jones's name to Parks. 29.

For member#. Include the follow ing fields member#. data type is text and fie ld size is 12. let Access fill that in for you. Create a table with the same name as your last name. caprate DOUBLE. lastname CHAR). This table will have 7 fields in it. CREATE TABLE GOLDBERG ([member#] CHAR(12). For ymdend data type is data/time. . For firstname datatype is text and field size is 14. PCP DR. caprate. ymdeff DATETIME. Include the follow ing fields member#. level. lastname. Create a table with the same name as your first name. For lastname data type is text. Don't assume the d efault size is 50. level LONG).sonBackup UPDATE TBLSALESPERSON SET NAME = 'PARKS' WHERE NAME = 'JONES'. Fo r member#. data type is text and field size is 12. For ymdeff datatype is date/t ime. firstname CHAR(14). For level the data type is number and the field size is long integer. yearsexperience. yearsexperience SHORT. firstname. For PCP DR the data type is text and fie ld size is 49. ymdend. CREATE TABLE BRIAN ([member#] CHAR(12). ymdeff. use the default size for the fields size. For caprate the data type is number and field size is double. 33. ymdend DATETIME. For yearsexperience the datatype is number and field size is inte ger. [PCP DR] CHAR(49).