SQL syntax producing duplicate results

I have an SQL query that is producing overstated records.  I have 2 tables, History_1 and History_2 tables.  History 1 has multiple data rows matching Call_ID which is creating overstated results.  What I need to happen is only to match against 1 of the mutiple data matching records to produce accurate results.  I have attached the SQL Syntax.  Thanks.
Use Dialer

Select
Facility_Name As "Facility",
History_1.Client As "Client",
Count(History_1.Client) As "Count"

From
History_1,
History_1,
LU_Clients

Where
History_1.Call_ID = History_2.Call_ID and
History_1.Client = LU_Clients.Facility_ID

Group By
History_1.Client,
Facility_Name

Open in new window

OB1CanobieAsked:
Who is Participating?
 
tigin44Connect With a Mentor Commented:
I missed a point in the above post... try this...
Use Dialer

Select
Facility_Name As "Facility",
History_1.Client As "Client",
Count(History_1.Client) As "Count"
From History_1
		INNER JOIN History_2 ON History_1.Call_ID = History_2.Call_ID  
		INNER JOIN LU_Clients ON History_1.Client = LU_Clients.Facility_ID
Group By
History_1.Client,
Facility_Name

Open in new window

0
 
tigin44Commented:
try this
Use Dialer

Select
Facility_Name As "Facility",
History_1.Client As "Client",
Count(History_1.Client) As "Count"
From History_1
		INNER JOIN History_1 ON History_1.Call_ID = History_2.Call_ID  
		INNER JOIN LU_Clients ON History_1.Client = LU_Clients.Facility_ID
Group By
History_1.Client,
Facility_Name

Open in new window

0
 
HainKurtSr. System AnalystCommented:
is it a type? you used History_1 twice in from part without an alias

try this, and add aliases to the all columns first:

...
From
      History_1 h1,
      History_1 h2,
      LU_Clients lu
Where
...
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
OB1CanobieAuthor Commented:
Thanks.  This fixed the replication.
0
 
HainKurtSr. System AnalystCommented:
tigin44, whats the difference between the one accepted and original query?
they should give the same result!...
0
 
tigin44Commented:
the user has two tables named History_1 and History_2... I used them...
0
 
HainKurtSr. System AnalystCommented:
oooh, same observation as 26149492 ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.