Need help to make a SQL statement

M

Mota

Hello;
In a medical system we have a table to store our prescriptions, named
prescriptionsTBL.This table has some fields such as [PID] as its primary
key,[DOP] or DateOfPrescription,[SumPrice] and so on.In this table,each
prescription get a unique PID and has a record for itself.So at the month
end,number of records shows Count of all Prescriptions we had at this
month.Now what i want is to know Average of daily Prescription Count thru
this month.In other word,averagely how many prescription we have dispensed
in a day of this month?So, the query returns just one number,mostly a
Single.Can anyone please help me to make a SQL statement for this query?
Thank you so much for ur help.
 
R

Rick Brandt

Mota said:
Hello;
In a medical system we have a table to store our prescriptions, named
prescriptionsTBL.This table has some fields such as [PID] as its primary
key,[DOP] or DateOfPrescription,[SumPrice] and so on.In this table,each
prescription get a unique PID and has a record for itself.So at the month
end,number of records shows Count of all Prescriptions we had at this
month.Now what i want is to know Average of daily Prescription Count thru
this month.In other word,averagely how many prescription we have dispensed
in a day of this month?So, the query returns just one number,mostly a
Single.Can anyone please help me to make a SQL statement for this query?
Thank you so much for ur help.

A bit easier with two queries. Make one that groups by day and uses Count(PID).
That will give the daily count. Then use that query as the input into another
where you can use the Avg() on the Count field.

Or you could have the one query and then use DAvg() function against it.
 
M

Mota

Yes,it work with 2 queries.
So,i got sure its not possible thru 1 query.and this was the thing i had
doubts in.
Thank you for the assurness you gave to me.

Rick Brandt said:
Mota said:
Hello;
In a medical system we have a table to store our prescriptions, named
prescriptionsTBL.This table has some fields such as [PID] as its primary
key,[DOP] or DateOfPrescription,[SumPrice] and so on.In this table,each
prescription get a unique PID and has a record for itself.So at the month
end,number of records shows Count of all Prescriptions we had at this
month.Now what i want is to know Average of daily Prescription Count thru
this month.In other word,averagely how many prescription we have dispensed
in a day of this month?So, the query returns just one number,mostly a
Single.Can anyone please help me to make a SQL statement for this query?
Thank you so much for ur help.

A bit easier with two queries. Make one that groups by day and uses Count(PID).
That will give the daily count. Then use that query as the input into another
where you can use the Avg() on the Count field.

Or you could have the one query and then use DAvg() function against it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top