| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

01-07-09, 10:10
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 5
|
|
Please HELP ME
|
|
i am new to sql and i need a way urgently of displaying a table with data from an existing database:
There is one table called ward that has the following colums
name
ward_no
number_of_beds
note: this table only has the total number of beds
The next table i have is patient that has the following colums
name
patient_no
ward_no
For each ward, give the ward number and name, the number of occupied beds and the number of empty beds on that ward.
i need the most effective way posible, thanks for anyhelp you can give
Please help!
Thanks
btw i am using my sql
|
|

01-07-09, 10:37
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
|
|
so what have you rtied so far
does the assignement expect you to use a front end language, and the results all in a single block,
or do you meet the requirement by a series of SQL statements?
so you need to do a JOIN between the tables
you need to do a COUNT
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

01-07-09, 10:45
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 5
|
|
|
|
i am expected to make one table by typin commands into dos my sql interface.
i have tried to join and count until my head hurts
thanks
|
|

01-07-09, 10:48
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
|
|
so lets see what you have tried...
lets see some test data...
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

01-07-09, 12:42
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 440
|
|
Please don't be lazy and post threads with Please HELP ME in the title, it is a waste of people's time, it tells nothing about what the thread is about.
By the way needing an ambulance is urgent, needing help with sql isn't.
|
|

01-07-09, 12:57
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 5
|
|
gualphdad, thanks for being basicly useless
how do you know that needing help with sql isnt? do you know the details surrounding the urgency....nope. dont wanna help then dont
i am a bit disapointed with this forum, i am not an sql programer.
does anybody know how to preform this basic task?
|
|

01-07-09, 13:16
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
|
|
yes I have some working SQL..... but as (in my judgement its schoolwork, or college,or uni) I'm not prepared to show it. its a bit like being back in primary school.. I show you mine if you show me yours.
Im guessing the other contributors here also worked out this is homework, the urgency is that you need to hand in a piece of work.
whether you are dissapointed or not doesnt' matter one iota to me or other contributors to this forum, after all you've paid nowt, you shouldn't execpt owt. youve done nowt, y'shouldn't expect owt
ultimately your are betraying yourself by not doing the work yourself. have you followed up the clues in poist #2 ie look at and understand the count verb
you cannot expect this forum to provide a solution (the forum will help if they are so minded, bear in mind that they are all unpaid and volunteer their time so its unreasonable of you to demand anything.
if you are unable or unwilling to go donw the path of at least making an effort its highly unlikely you will get any response.
if you want beginners SQL there are places like w3schools which maybe a better place.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

01-07-09, 13:34
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 5
|
|
right ok i am not at school or whatever i havent come accros this attitude before. i am using the database example given as i do not wish to provide details of the real database as it is personal however it has similar colums
i have this code btw which i thought would work but it doesnt.
SELECT w.ward_no as wardno,
w.name as wardname,
p.occupied as occupiedbeds
w.number_of_beds-p.occupied AS emptybeds
FROM ward w
INNER JOIN (SELECT ward_no,COUNT(patient_no) as occupied
FROM patient
GROUP BY ward_no) p
ON p.ward_no=w.ward_no
i more often than not use a different lang but it has worked out i have had to resort to sql in this case.
|
|

01-07-09, 16:08
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 440
|
|
you posted a thread with a useless title, no one who is looking to assist will know what the thread is about, no one looking for help will know if your thread is about a similar problem that they are having.
as for the urgency, same thing as the thread title, if you aren't paying for the help it isn't urgent.
if you'd have posted the query you have here then people would know you have attempted to do some of the work yourself and aren't trolling for homework answers, this may be new to you but isn't to regular posters.
can you post some sample rows from these tables and expected output, and no it doesn't matter that these aren't your real table or real data, only that the data and question reflect what you are looking to accomplish. Believe it or not people start off thread with sample tables/data that turn out to be nothing like the solution they need in the end.
|
|

01-07-09, 16:25
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 5
|
|
its ok i figured it out now.... i didnt think it was so simple 
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|