I am not sure if anyone will be interested in helping a self starter without much knowledge. I have ordered an SQL book but do not have it yet.
I am getting data and have tried select distinct multiple ways and a union command, no luck removing duplicates.
The patid, appt date and the adacode need to drive the removal of duplicates. When i do the Select distinct I only get two fields. I tried more fields and got errors. I tried the Union and same thing errors. Because I am starting out and not knowledgeable enough, I need help! My code is below.
What I have tried:
Select rb.city,
ab.PATID,
pb.firstname,
pb.lastname,
clb.idnum,
pb.firstvisitdate,
pb.lastvisitdate,
ab.apptdate,
CodeB.adacode,
CodeB.description,
LogB.Amount,
InsB.groupname,
InsB.insconame,
Instb.copayment,
Logb.chart_status
FROM ddb_appt_base AS ab
INNER JOIN ddb_pat_base AS pb
ON ab.patid = pb.patid
INNER JOIN ddb_insured_base AS ib
ON pb.patid = ib.insuredid
INNER JOIN ddb_insurance_base AS InsB
ON ib.insid = InsB.insid
INNER JOIN DDB_PROC_LOG_BASE AS LogB
ON ab.PATID = LogB.PATID
Inner Join DDB_PROC_CODE AS CodeB
On codeb.proc_codeid = LogB.proc_codeid
Inner Join DDB_RSC_BASE AS rb
On rb.urscid = Logb.clinicappliedto
Inner Join DDB_INSTABLE_BASE As Instb
On ib.insid = instb.insid
Inner Join ddb_claim_base AS clb
ON clb.patid = ab.patid
WHERE ab.apptdate BETWEEN '2016-05-01 00:00:00.000' AND
'2017-04-30 00:00:00.000'
AND InsB.insid IN ( '1002420', '1002707', '1003104', '1003096',
'1002814', '1002820', '1002439', '1002579', '1003132'
)
AND rb.city IN ( 'Anderson')