homerUK
02-18-2008, 12:10 PM
hi guys,
I've got another problem with my join. I have two tables
orgparamanswers
=============
orgParamID
year
answer
servicelineID
orgID
orgparams
========
orgParamID
name
I need to get the answers in the orgparamanswers table based on the orgID specified. The trouble is, there seems to be some duplicated answers (that's another problem for another time!) ... so I need to get the distinct rows of data for a year, servicelineID and orgPAramID.
that seems OK, but when I join the orgparam table, it's getting the wrong orgparam name. Is there a problem with the join which is fetching too many rows??
=====================
select
distinct opa.orgparamID, opa.year, opa.serviceLineID,
opa.answer,
op.name
from
orgparamanswers opa
INNER JOIN orgparams op
ON opa.orgParamID = op.orgParamID
WHERE opa.orgID="xxxxx"
ORDER BY opa.orgID, opa.orgParamID asc, opa.serviceLineID asc
======================
thanks for any help!!
I've got another problem with my join. I have two tables
orgparamanswers
=============
orgParamID
year
answer
servicelineID
orgID
orgparams
========
orgParamID
name
I need to get the answers in the orgparamanswers table based on the orgID specified. The trouble is, there seems to be some duplicated answers (that's another problem for another time!) ... so I need to get the distinct rows of data for a year, servicelineID and orgPAramID.
that seems OK, but when I join the orgparam table, it's getting the wrong orgparam name. Is there a problem with the join which is fetching too many rows??
=====================
select
distinct opa.orgparamID, opa.year, opa.serviceLineID,
opa.answer,
op.name
from
orgparamanswers opa
INNER JOIN orgparams op
ON opa.orgParamID = op.orgParamID
WHERE opa.orgID="xxxxx"
ORDER BY opa.orgID, opa.orgParamID asc, opa.serviceLineID asc
======================
thanks for any help!!