Need help to make a SQL statement

  • Thread starter Thread starter Mota
  • Start date Start date
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.
 
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.
 
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.
 
Back
Top