I want to analyze SQL query to know which hard coded values are belonging to which column? For e.g I have a following SQL query:-
SELECT *
FROM (
SELECT DISTINCT id
,substring([data], 0, 497) AS [Instructions]
,'500' AS [Care_Code]
,cast(id AS VARCHAR) + cast(number AS VARCHAR) + 'pp' AS key
FROM people
WHERE ([data] LIKE '%communicated %')
UNION ALL
SELECT DISTINCT Patientid
,substring(pp, 0, 497) AS [Instructions]
,'500' AS [Care_Code]
,cast(id AS VARCHAR) + cast(number AS VARCHAR) + 'aa' AS key
FROM people
WHERE Instructions LIKE '%[A-Z]%'
I want the output to be like:-
Harcoded_value Column_Name
500 Care_Code
%communicated % data
%[A-Z]% Instructions
Example 2:-
Query :-
select distinct eid, count(distinct d.pid)
from SOAP s
inner join demographics d on s.pid=d.pid
inner join PS p on p.providerId=s.pid
where
p.npi in ('1316987761','1437366473','1912915638','1740253822')
and Convert(datetime,Convert(varchar,EncounterDate,101)) >='08/01/2016'
and Convert(datetime,Convert(varchar,EncounterDate,101)) <= '07/31/2017'
group by eid
Expected Output:-
Harcoded_value Column
('1316987761','1437366473','1912915638','1740253822') p.npi