Go4Expert (http://www.go4expert.com/)
-   Oracle (http://www.go4expert.com/forums/oracle-forum/)
-   -   A really simple SQL query (http://www.go4expert.com/forums/simple-sql-query-t14429/)

Lokantis 8Oct2008 03:21

A really simple SQL query
Hello, I am a total noobie at SQL and I still don't understand all the concepts. I want to see how to solve this first query and hopefully I'll be able to go from there.
I have this database:
Customer (CustNo, CustFirstName, CustLastName, CustStreet, CustCity, CustState, CustZip, CustBal)

Employee (EmpNo, EmpFirstName, EmpLastName, EmpPhone, EmpEmail, SupEmpNo, EmpCommRate)

Product (ProdNo, ProdName, ProdMfg, ProdQOH, ProdPrice, ProdNextShipDate)

OrderTbl (OrdNo, OrdDate, CustNo, EmpNo, ShpName, ShpStreet, ShpCity, ShpState, ShpZip)

OrdProd (OrdNo, ProdNo, Qty)

2 answers: first one using 3 simple subqueries nested, second one with JOIN (using no subqueries).
List the product number, name, and price of those products with a price greater than $150 and were ordered in Jan 2008 by customers with balances greater than $400.

Thank you in advance.

xpi0t0s 9Oct2008 21:11

Re: A really simple SQL query
It's not that simple...
Try building the query bit by bit rather than trying to do the whole lot at once.
So for example you could start with "List the product number, name, and price", which translates fairly easily into SELECT ProdNo, ProdName, ProdPrice FROM Product;
"Price greater than $150" leads to a fairly obvious WHERE clause.
Then just continue adding bit by bit, checking as you go along against your test data that correct data is returned and incorrect data is not (both are important) until you have the full query.

All times are GMT +5.5. The time now is 07:09.