May 9, 2013 at 3:01 am
Hi All. Below is an example table of what i need to query out of:
Patient Name, Patient No., Age, Cancer, Consultant, Operation
Joe Bloggs 123 25 Yes Dr Smith Back
Joe Bloggs2 321 29 NO Dr loggs Spine
I need a simple query to find the average age from the table and also to find the percentage of patients with cancer and percentage of patients without cancer . thanks
May 9, 2013 at 3:19 am
Is this homework? Please show us what you've tried so far, and we'll see if we can help with where you're going wrong?
John
May 9, 2013 at 4:28 am
sorry ive got this working. what i need now is code to find the number of operations per consultant soo it looks like this:
COnsultant Total no. of operations
Dr Bloggs 23
Dr Doe 20
Sr Smith 14
i have the following code
select COUNT(operation) as [number of operations]
from tablenamewhere (Consultant = 'Dr Bloggs' or Consultant = 'Dr Smith' or Consultant = 'Dr Doe') but this is wrong.
May 9, 2013 at 4:40 am
You need to use a GROUP BY clause.
John
May 9, 2013 at 4:44 am
ive added the group by but it results to this
no of operations
1
2
5
7
when i need it to result like this:
Consultant name No. of operations
Dr Smith 3
Dr Bloggs 5
Dr Doe 20
May 9, 2013 at 4:47 am
prb88 (5/9/2013)
ive added the group by but it results to thisno of operations
1
2
5
7
when i need it to result like this:
Consultant name No. of operations
Dr Smith 3
Dr Bloggs 5
Dr Doe 20
Just a guess:
select
COUNT(operation) as [number of operations]
,Consultant
from
tablename
where (Consultant = 'Dr Bloggs' or Consultant = 'Dr Smith' or Consultant = 'Dr Doe')
group by
Consultant
==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
May 9, 2013 at 4:51 am
cheers Andy helped a lot 😉
May 10, 2013 at 4:44 am
No Probs 🙂
==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply