pls help me to write sql queries
Pls help me to write sql queries.....
Create table Customer (
Cust_Id number (10),
CName varchar2 (15),
City varchar2 (10),
Primary key (Cust_id)
);
Create table Order (
Order_No number (10),
ODate date,
Cust_Id number (10),
Ord_Amt number (10, 2),
Primary key Order_No
);
Create table Order_Item (
Order_No number (10) references Order,
Item_No number (10) references item,
Qty number (4)
);
Create table Item (
Item_No number (10),
Unit_Price number (10, 2),
Primary key (Item_Id)
);
Create table Shipment (
Order_No number (10) references Order,
Ship_Date date,
Warehouse_No number (4)
);
Create table Warehouse (
Warehouse_No number (4),
City varchar2 (10),
Primary key (Warehouse_Id)
);
1. Produce a listing: CustName, #of_orders, Avg_Order_Amt, where the middle column is the total numbers of orders by the customer and the last column is the average order amount for that customer.?
2. List the order# for orders that were shipped from all the warehouses that the company has in a specific city.?
----------------------------------------------------------------------
Create table Student (
Stu_RegNo number (10),
Stu_Name varchar2 (15),
Stu_Major varchar2 (10),
Stu_Bdate date,
Primary key (Stu_RegNo)
);
Create table Course (
Course_No number (10),
CName varchar2 (10),
CDept varchar2 (10),
Primary key (Course_No)
);
Create table Enroll (
Stu_RegNo number (10) references Student,
Course_No number (10) references Course,
Semester number (10),
Marks number (5)
);
Create table Book_Adoption (
Course_No number (10),
Semester number (10),
Book_ISBN number (10)
);
Create table Text (
Book_ISBN number (10),
Book_Title varchar2 (20),
Publisher varchar2 (15),
Author varchar2 (15),
Primary key (Book_ISBN)
);
1. Demonstrate how you add a new text book to the database and make this book be adopted by some department.?
2. Produce a list of text books (include Course#, Book_ISBN, Book_Title) in the alphabetical order for courses offered by the âCSâ department that use more than two books.?
3. List any department that has all its adopted books published by a specific publisher.?
----------------------------------------------------------------------
Create table Author (
Author-Id number (10),
Name varchar2 (15),
City varchar2 (10),
Country varchar2 (10),
Primary key (Author-Id)
);
Create table Publisher (
Publisher-Id number (10),
Name varchar2 (10),
City varchar2 (10),
Country varchar2 (10),
);
Create table Catalog (
Book-Id number (10),
Title varchar2 (10),
Author-Id number (10),
Publisher-Id number (10),
Category-Id number (10),
Year number (4),
Price number (10, 2),
Primary key (Book-Id)
);
Create table Category (
Category-Id number (9),
Description varchar2 (10),
Primary key Category-Id
);
Create table Order-Details (
Order-No number (10),
Book-Id number (10),
Quantity number (5)
);
1. Give the details of the authors who have 2 or more books in the catalog and the price of the books is greater than the average price of the books in the catalog and the year of publication is after 2000.?
2. Find the author of the book which has maximum sales.?
3. Demonstrate how you increase the price of books published by a specific publisher by 10%.?
----------------------------------------------------------------------
Create table Branch (
Branch-Name varchar2 (15);
Branch-City varchar2 (15);
Assets number (20, 2);
);
Create table Account (
Account-No number (10);
Branch-Name varchar2 (15);
Balance number (10, 2);
);
Create table Depositor (
Customer-Name varchar2 (20);
Account-No number (10);
);
Create table Customer (
Customer-Name varchar2 (20);
Customer-Street varchar2 (20);
Customer-City varchar2 (20);
);
Create table Loan (
Loan-Number number (10);
Branch-Name varchar2 (15);
Amount number (10, 2);
);
Create table Borrower (
Customer-Name varchar2 (20);
Loan-Number number (10);
);
1. Find all the customers who have at least two accounts at the Main branch.?
2. Find all the customers who have an account at all the branches located in a specific city.?
3. Demonstrate how you delete all account tuples at every branch located in a specific city.?
Can any one please help me.... THANKS IN ADVANCE..
Regards
sush
|