I have a table that records history of procedures by surgeons. I can get the history time history for all records for a certain surgeon, but I NEED to get just history for the last 5 or 10 or whatever number the user wants. We don't want this history go back forever.
Below is the code I started with that get everything:
lcsql=''
lcsql=lcsql+[SELECT CQIPROCEDURES.ProcCode, CQIPROCEDURES.description, CQIPROCEDURES.ProcedureID, AvgTime=avg(procseconds), numdone=count(CQIPROCEDURES.ProcedureID) ]
lcsql=lcsql+[FROM CQIPROCHIS INNER JOIN ]
lcsql=lcsql+[CQIPROCEDURES ON CQIPROCHIS.ProcID = CQIPROCEDURES.ProcedureID ]
lcsql=lcsql+[WHERE CQIPROCHIS.SurgeonID = ?gnCurrentSurgeonID ]
lcsql=lcsql+[group by proccode,description,procedureid ]
lcsql=lcsql+[order by 1 ]
What I display based on Results (shortened)
--------------------------------------------------
code description AvgTime Count
--------------------------------------------------
53.21 Lap Chole 5400 125
53.01 Laprascropic Proc 6430 75
What I Need to to cut the count on each procedure down
to the last 10 cases or whatever number the user has set.
Thanks for any input