Programming

SQL Problem Part 1

March 24, 2014

Hi guys, I’m back! I have some good news to yah. Classes are over and it’s summer time! :))))))))))

I’ll be posting some of my programming problems at the same time the SQL codes and its output. 😉

OH by the way, congratulations to Class 2014 especially to my sister. Just graduated last March 22,2014 (BSBA-MA), and of course to my lil’ brother who will be graduating this coming March 27, 2014 (Grade 6). Me? Well not today or this year, but sooooooooonnest. haha 🙂

I just want to clarify that I don’t have the copy of the tables of this problem. Our professor just provided it to us and we answered it right away.  So let’s start shall we? 🙂

PS: I was assigned to answer EVEN NUMBERS ONLY.

Query2.  Find the customer name, address, city and pincode for the client who has placed order no “019001”.

Code:
SELECT [ClientName], City, State, PincodeFROM 
Client, SalesOrder
WHERE Client.Clientno=SalesOrder.Clientno And SalesOrder.[SOrderNo]='019001';

Output:
Query2

Query2

Query4. Find out if product “1.44 Drive” is ordered by only client and print the client_no name to whom it was sold.

Code:

SELECT ClientNo
FROM SalesOrder
WHERE `SOrderNo` = 
(SELECT `SOrderNo` FROM `SalesOrderDetail` WHERE ProductNo=
(SELECT ProductNo FROM Product WHERE Description="1.44 Drive"));

Output:
Query4

Query4

Query8. Select the names of persons who are in Mr. Pradeep’s department and who have also worked on an inventory control system.

Code:

SELECT ClientName as 'Name'
FROM Client
WHERE Client.City  = 'Bombay' 
UNION ALL SELECT `Salesmanname` as 'Name'
FROM SalesTable
WHERE SalesTable.City  = 'Bombay';

Output:
Query8

Query8

Query10.  Select the product_no, description, qty_on_hand, cost_price of non-moving items in the product_master_table.

Code:

SELECT ProductNo, Description, `Qty_on-hand`, CostPrice
FROM Product
WHERE Product.Description = 'Monitors' OR Product.Description = 'Mouse' 
OR Product.Description = 'Keyboards';

Output:
Query10

Query10

Part 1 is now all set and of course I’ll be posting also the part 2 and part 3 of this problem. Since, it has 3 sets of problems. 🙂

If there’s anything wrong of my codes, just message me up and make it right…

 

-Tinay


 

 

 

You Might Also Like...

1 Comment

  • Reply
    Lysander
    March 27, 2014 at 3:52 am

    Hahaha, tin wa ko ka get over ani hahaha 😀

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.