我想分析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]%'
我希望输出是like:-
Harcoded_value Column_Name
500 Care_Code
%communicated % data
%[A-Z]% Instructions
例2:-
查询:-
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
预期output:-
Harcoded_value Column
('1316987761','1437366473','1912915638','1740253822') p.npi
1条答案
按热度按时间ttcibm8c1#
你可以试试
输出
此代码将从查询中提取包含“”的所有值,以及like之前或as之后的单词,而不是名称
key
并将其存储在结果字典中。在收集了所有的值之后,它将创建一个包含列的Dataframe
"Harcoded_value"
以及"Column_Name"