Forum Moderators: open

Message Too Old, No Replies

SQL Statement Help

Need a hand doing some simple mySQL5 statements...

         

sqln00b

2:20 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



Hi Guys,

Im not gonna beat around the bush, i have pretty much no clue about sql statements, and need this done to pass my coursework. Any help would be GREATLY appreciated....

The relational schema shown below is part of a hospital database.

Patient (patientNo, patName, patAddr, DOB) Ward (wardNo, wardName, wardType, noOfBeds)
Contains (patientNo, wardNo, admissionDate) Drug (drugNo, drugName, costPerUnit)
Prescribed (patientNo, drugNo, unitsPerDay, startDate, finishDate)

Formulate the following SQL statements using MySQL5;

a. List all the patients’ details, alphabetically by name.
b. List all the patients contained in the ‘Surgical’ ward.
c. List all the patients admitted today.
d. Find the names of all the patients being prescribed ‘Morphine’.
e. What is the total cost of Morphine supplied to a patient called ‘John Smith’ ?
f. What is the maximum, minimum and average number of beds in a ward? Create appropriate column headings for the results table.
g. For each ward that admitted more than 10 patients today, list the ward number, ward type and number of beds in each ward.
h. List the numbers and names of all patients and the drugNo and number of units of their medication. The list should also include the details of patients that are not prescribed medication.

I realise this is a big ask, but no harm in trying..

Cheers

DWarp9

3:33 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



It is a fairly big thing to ask of already busy webmasters (myself not included), and since SQL is failry straightforward with a very manageable learning-curve I would recommend you simply take the time to learn SQL.
Google w3schools (or guess the address :-)) and run over their SQL tutorial, it is excellent and I gurantee you will be able to write the statements yourself by the end of it.

For a) look at select statements, b) c) d) look at inner joins, e) f) g) look at group by and aggregate functions, and h) look at outer joins.

Clever assignment as you'll know most of the statements in standard SQL once you've written the statements.

Good luck.
-Peter

sqln00b

5:50 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



Ok peter i will check it out.

Thanks for your help.

The offers still there for anyone who wants to do some for me....ha

rocknbil

11:56 pm on Jul 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



w3schools (or guess the address)

This may lead to a worthless copycat domain name link farm site - I kick myself every time I accidentally go there. The URL to W3Schools is http://www.w3schools.com/ [w3schools.com]

A better resource in this case might be the mySQL documentation: http://dev.mysql.com/doc/ [dev.mysql.com]. Not so great for tutorials, but lots of examples you can learn by.

Welcome aboard, unfortunately "homework assistance" is disallowed by the TOS [webmasterworld.com].

sqlnoob2

4:05 pm on Aug 15, 2009 (gmt 0)

10+ Year Member



Why don't you ask Devitt? ;)