I have a query that returns results from the database. It returns duplicate information. I would like to prevent showing the duplicate data.
What I mean by duplicate data is that the Admit Date, Service Date, and Discharge Date columns repeats the same data (in this case dates). So if the date is 10/05/2019, for Admit Date, it will repeat the date 2 or more times. This is due to the Process Date column where the process of submitting the inquiry were done in different dates and causes the other dates to repeat twice.
I originally tried using SELECT DISTINCT Column1, Column2, ... FROM Data
in my query but it errors outs. The following is the error I am getting:
Error Executing Database Query. [Macromedia][SQLServer JDBC Driver][SQLServer]The text data type cannot be selected as DISTINCT because it is not comparable.
What am I doing wrong? Any help would be appreciated
Here is my latest attempt:
<cfquery name="name" datasource="source">
SELECT First_Name,
Last_Name,
DOB, Sex,
Service,
Service_Desc,
Distinct(service_dt) AS Service_Dt,
Distinct(admit_dt) AS Admit_Dt,
Phone,
Address1,
Address2,
City,
State,
Zip,
Account,
Hosp_Name,
MR_Number,
Insurance,
Plan_Name,
Policy_No,
Group_No,
Reason_For_Visit,
Distinct(process_dt) AS Process_Dt,
Distinct(discharge_dt) AS Discharge_Dt,
[Pt Class] as PtClass
FROM DATA
WHERE
First_Name = <cfqueryparam value="#FName#" cfsqltype="cf_sql_varchar">
AND
Last_Name = <cfqueryparam value="#LName#" cfsqltype="cf_sql_varchar">
AND
DOB = <cfqueryparam value="#BirthDt#" cfsqltype="cf_sql_varchar">
AND
Hosp_Name like <cfqueryparam value="#Hosp#" cfsqltype="cf_sql_varchar">
</cfquery>