not enough unique variables

T

tim

i have a query, based on another query, with only 5
variables.

Key ProviderId Proc ProcDesc SvcDate

the original query takes all Proc & ProcDesc for 1
Provider for each Key, and return the SvcDate as well, so
that the output would look something like:

key_ provid px pxdesc svc_date
2 0400740 93016 STRESS TEST 1 26-Feb-97
2 0400740 93018 STRESS TEST 2 26-Feb-97
2 0400740 93307 ECG THOR 26-Feb-97
2 0400740 93320 DOPPLER ECHO 26-Feb-97
2 0400740 99254 OFFICE VISIT 09-Apr-97
2 0400740 93307 ECG THOR 11-Apr-97*
2 0400740 93320 DOPPLER ECHO 11-Apr-97*
2 0400740 93325 DOPPLER COLOR 11-Apr-97

Now, I need another query that assigns an arbitrary rank,
by Key and Date. This is my SQL, and the problem is that
it returns, for example "4" for each instance of
key=2,px=93320. if i had more unique variables i could
add additional criteria, but I can't do this, becaue
adding a unique variable throws off the count as-is, which
is otherwise correct. Advice? TIA!

SQL:
SELECT qsbListPx.key_, qsbListPx.svc_date, qsbListPx.px,
qsbListPx.pxdesc, (SELECT Count(px)
FROM qsbListPx AS a
WHERE a.key_ = qsbListPx.key_ AND a.px <= qsbListPx.px) AS
PxSequence
FROM qsbListPx
GROUP BY qsbListPx.key_, qsbListPx.svc_date, qsbListPx.px,
qsbListPx.pxdesc
ORDER BY qsbListPx.key_, qsbListPx.svc_date, qsbListPx.px;
 

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