M
mota
Hello;
In a medical system,we have a table carrying all medicines of all
prescriptions of the current month.All data are saved as numeric,so we have
some look up tables for physicians name and ID,Drugs name and ID,and this
IDs are saved in our tables,rather than names.Fields of this table are as
follow:
RecID: an autonumber field just for having a primary key in table
PID: or physicianID that shows ID of the prescriber of each drug
DID: or DrugID that represents the ID of medicine that is prescribed by this
physician
Dnu: that is the quantity of this drug in its relative prescription (has
less importance in my query)
some other fields are TotalPrice,Date,PrescriptionID,InsuranceType and so
on.
As an example,we may have more than 1000 records relative to a specific
physician having PID=26,and 100 of this records can be for the drug Advil
(with DID=5),and near 80 records for Tylenol (DID=260),and so on.That means
Advil is 100 times prescribed by this physician in this month,and Tylenol
about 60 times and in 60 prescription.
Now,at the end of each month we want to know which medicines are more
interested by a specific physician.In other word,we want to select at least
top 20 medicines that are more frequent by the given physician (PID can be
passed to a function or query as its parameter).
The resulting query must have at least 1 field: DID (ID for more frequent
drug) and sorted Descending
So,in the example above,Advil must be the first selected record and Tylenol
the 2nd one.
Must consider that selecting this 20 records is kinda DistinctRow,otherwise
all 20 resulting records will be Advil !
I believe that having a new calculated field in resulting records,[Time of
Repeating],would complicate my SQL.But i will be glad if it is possible to
having that.
Can anyone please help me?I will so much grateful to you and thank you in
advance.
In a medical system,we have a table carrying all medicines of all
prescriptions of the current month.All data are saved as numeric,so we have
some look up tables for physicians name and ID,Drugs name and ID,and this
IDs are saved in our tables,rather than names.Fields of this table are as
follow:
RecID: an autonumber field just for having a primary key in table
PID: or physicianID that shows ID of the prescriber of each drug
DID: or DrugID that represents the ID of medicine that is prescribed by this
physician
Dnu: that is the quantity of this drug in its relative prescription (has
less importance in my query)
some other fields are TotalPrice,Date,PrescriptionID,InsuranceType and so
on.
As an example,we may have more than 1000 records relative to a specific
physician having PID=26,and 100 of this records can be for the drug Advil
(with DID=5),and near 80 records for Tylenol (DID=260),and so on.That means
Advil is 100 times prescribed by this physician in this month,and Tylenol
about 60 times and in 60 prescription.
Now,at the end of each month we want to know which medicines are more
interested by a specific physician.In other word,we want to select at least
top 20 medicines that are more frequent by the given physician (PID can be
passed to a function or query as its parameter).
The resulting query must have at least 1 field: DID (ID for more frequent
drug) and sorted Descending
So,in the example above,Advil must be the first selected record and Tylenol
the 2nd one.
Must consider that selecting this 20 records is kinda DistinctRow,otherwise
all 20 resulting records will be Advil !
I believe that having a new calculated field in resulting records,[Time of
Repeating],would complicate my SQL.But i will be glad if it is possible to
having that.
Can anyone please help me?I will so much grateful to you and thank you in
advance.