0% found this document useful (0 votes)
11 views4 pages

Queries Final

The document outlines the structure and data for four tables: Customer, Item, Invoice, and Invitem, including their attributes, data types, sizes, and constraints. It also provides a series of SQL tasks to create these tables, insert data, and perform various queries such as displaying customer information, item prices, and invoice details. Additionally, it includes operations for sorting, filtering, and manipulating the data, as well as creating views, sequences, and synonyms.

Uploaded by

giftedmoore3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Queries Final

The document outlines the structure and data for four tables: Customer, Item, Invoice, and Invitem, including their attributes, data types, sizes, and constraints. It also provides a series of SQL tasks to create these tables, insert data, and perform various queries such as displaying customer information, item prices, and invoice details. Additionally, it includes operations for sorting, filtering, and manipulating the data, as well as creating views, sequences, and synonyms.

Uploaded by

giftedmoore3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CUSTOMER (CustNo, CustName, State, Phone)

ITEM (ItemNo, ItemName, ItemPrice, QtyOnHand)

INVOICE (InvNo, InvDate, CustNo)

INVITEM (InvNo, ItemNo, Qty)

Customer:

Attribute Name Data type Size Constraints


CustNo Number 3 Primary key
CustName Varchar2 10 Not Null
State Char 2
Phone Char 12 +

Item:

Attribute Name Data type Size Constraints


ItemNo Number 2 Primary key
ItemName Varchar2 6
ItemPrice Number 3,2
QtyOnHand Number 3 >= 0

Invoice:

Attribute Name Data type Size Constraints


InvNo Number 4 Primary key
InvDate Date
CustNo Number 3 Foreign Key

Invitem

Attribute Name Data type Size Constraints


InvNo Number 4 Foreign Key
ItemNo Number 2 Foreign Key
Qty Number 2 Not Null
Data:

Customer:

CustNo CustName State Phone


211 Garcia NJ 732-555-1000
212 Parikh NY 212-555-2000
225 Elsenhaur NJ 973-555-3333
239 Bayer FL 407-555-7777

Item

ItemNo ItemName ItemPrice QtyOnHand


1 Screw 2.25 50
2 Nut 5.00 110
3 Bolt 3.99 75
4 Hammer 9.99 125
5 Washer 1.99 100
6 Nail 0.99 300

Invoice

InvNo InvDate CustNo


1001 05-SEP-03 212
1002 17-SEP-03 225
1003 17-SEP-03 239
1004 18-SEP-03 211
1005 21-SEP-03 212

INVITEM

InvNo ItemNo Qty


1001 1 5
1001 3 5
1001 5 9
1002 1 2
1002 2 3
1003 1 7
1003 2 1
1004 4 5
1005 4 10
1. Create the following tables: Customer, Item, Invoice, Invitem

2. Insert values in to the above mentioned tables

3. Display all customer information

4. Display all item names and their respective unit price

5. Display unique invoice numbers from the INVITEM table.

6. Display item information with appropriate column aliases.

7. Display Item name and price using concatenation.

8. Find the total value of each item based on quantity on hand.

9. Find customers from Florida.

10. Display items with a unit price of atleast 5.

11. Find items with a unit price between 2 and 5.

12. Find customers from the tristate area of New York, New Jersey and Connecticut.

13. Find all customers whose name starts with the letter E.

14. Find items with the letter W in their name.

15. Sort all Customers Alphabetically.

16. Sort all items in Descending Order by their Price.

17. Sort all Customers by their state and also alphabetically.

18. Display all customers from New Jersey Alphabetically.

19. Display all item prices Rounded to the Nearest amount.

20. Find the payment Due Date if the payment is Due in Two Months from the invoice Date.

21. Display invoice Dates in “September 05,2003” format.

22. Find the Total, Average, Highest, and Lowest Unit Prices.

23. Display How many Different items are available for Customers.

24. Count the Number of items ordered in Each Invoice.

25. Find invoices in which Three or More items are ordered.

26. Find all possible Combinations of Customers and items (Cartesian Product).

27. Display all item Quantities and item prices for invoices.

28. Find the total price for each invoice.

29. Use an outer join to Display items ordered and Not ordered.
30. Display invoices, Customer Names, and item Names together (Multiple Joins).

31. Find invoices with HAMMER as an item.

32. Find invoices with HAMMER as an item by Using a Subquery.

33. Display the items Ordered in Invoice Number 1001 (Subquery).

34. Find items that are Chapter than NUT.

35. Create a New Table for all New Jersey Customers Based on the Existing CUSTOMER Table.

36. Copy all New York Customer to the Newly Created NJ_CUSTOMER Table.

37. Rename NJ_CUSTOMER Table to NYNJ_CUSTOMER.

38. Find Customers Who are not from New York or New Jersey (Set Operator).

39. Delete Rows from the CUSTOMER Table that Are also in the NYNJ_CUSTOMER Table.

40. Find the items with the Top-Three Prices.

41. Find the Two items with the lowest Quantity on Hand.

42. Create a Simple View with item Names and item Prices Only.

43. Create a View that Displays invoice Number and Customer Names for New Jersey Customers.

44. Create a Sequence that can be used to Enter New items into the ITEM Table.

45. Add a New item into the ITEM Table with the ITEMNUM_SEQ Sequence.

46. Create a Synonym for the INVITEM Table.

47. Create an index File Based on Customer Name.

48. Lock Customer Bayer’s Record to Update State and phone Number.

49. Give Everybody SELECT and INSERT Rights on Your ITEM Table.

50. Revoke the INSERT Option on the ITEM Table from User BOND.

You might also like