Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2005, 08:37 AM
Authorized User
 
Join Date: Dec 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sush_blr
Default 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
 
Old January 28th, 2005, 10:20 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is this a school assignment..?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine sql queries snufse SQL Server 2005 16 June 17th, 2008 03:47 PM
Prepared SQL VS. Regular Queries nikotromus Beginning VB 6 1 June 24th, 2006 10:08 AM
Anyone Expert in SQL Queries? itHighway HTML Code Clinic 3 June 3rd, 2005 09:57 AM
Anyone Expert in SQL Queries itHighway Classic ASP Basics 2 May 24th, 2005 03:37 AM
pls help SQL Queries sush_blr SQL Server 2000 2 February 1st, 2005 01:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.