我需要在我的巨大查询中添加另外几个左外连接。这对我来说变得越来越困难,因为查询太大了,我现在无法处理。我想知道是否有某种方法可以将查询自动转换为维恩图。
是否有工具可以进行查询并绘制代表查询的文图?
我正在寻找 sql server、c# 或 python 中的解决方案?
是否有一种自动化的方式来以图形方式表示查询?
WITH cte_biggie
AS (SELECT
LEFT('I'+Replicate(' ', 2), 2)
+ LEFT(CONVERT(VARCHAR, Getdate(), 110)+Replicate(' ', 10), 10)
+ LEFT('MILLENN'+Replicate(' ', 16), 16)
+ LEFT('TERR'+Replicate(' ', 12), 12)
+ LEFT(' '+Replicate(' ', 16), 16)
+ LEFT('IMS'+Replicate(' ', 8), 8)
+ LEFT(' '+Replicate(' ', 15), 15)
+ LEFT( LEFT( LEFT(Isnull(MLIS.requestor_first_name, 'XXX'),
Charindex(
' '
, Isnull
(MLIS.requestor_first_name, 'XXX') + ' ' ) - 1), Charindex( ' ',
LEFT(Isnull(MLIS.requestor_first_name, 'XXX'), Charindex( ' ',
Isnull(MLIS.requestor_first_name, 'XXX') + ' ' ) - 1) +
' ' ) - 1) +Replicate(' ', 25), 25)
+ LEFT(' '+Replicate(' ', 20), 20)
+ LEFT( LEFT( LEFT(Isnull(MLIS.requestor_last_name, ''),
Charindex(
',',
Isnull(
MLIS.requestor_last_name, '') + ',' ) - 1), Charindex( ',',
LEFT(Isnull(MLIS.requestor_last_name, ''), Charindex( ',',
Isnull(MLIS.requestor_last_name, '') + ',' ) - 1) +
',' ) - 1) +Replicate(' ', 25), 25)
+ LEFT(' '+Replicate(' ', 5), 5)
+ LEFT(' '+Replicate(' ', 3), 3)
+ LEFT(' '+Replicate(' ', 3), 3)
+ LEFT(' '+Replicate(' ', 3), 3)
+ LEFT(Isnull(MLIS.requestor_npi, '')+Replicate(' ', 12), 12)
+ LEFT('13'+Replicate(' ', 2), 2)
+ LEFT(' '+Replicate(' ', 15), 15)
+ LEFT(' '+Replicate(' ', 30), 30)
+ LEFT(' '+Replicate(' ', 15), 15)
+ LEFT(' '+Replicate(' ', 4), 4)
+ LEFT(' '+Replicate(' ', 2), 2)
+ LEFT(' '+Replicate(' ', 2), 2)
+ LEFT(' '+Replicate(' ', 1), 1)
+ LEFT(' '+Replicate(' ', 10), 10)
+ LEFT(' '+Replicate(' ', 2), 2)
+ LEFT(' '+Replicate(' ', 20), 20)
+ LEFT(' '+Replicate(' ', 10), 10)
+ LEFT(' '+Replicate(' ', 4), 4)
+ LEFT(' '+Replicate(' ', 100), 100)
+ LEFT(' '+Replicate(' ', 20), 20)
+ LEFT(' '+Replicate(' ', 12), 12)
+ LEFT(' '+Replicate(' ', 2), 2)
+ LEFT(' '+Replicate(' ', 1), 1)
+ LEFT(Isnull(SplitAddresses.address1, '')+Replicate(' ', 50), 50)
+ LEFT(Isnull(SplitAddresses.address2, '')+Replicate(' ', 50), 50)
+ LEFT(' '+Replicate(' ', 50), 50)
+ LEFT(' '+Replicate(' ', 50), 50)
+ LEFT(Isnull(CLIENT.mlis_client_city, 'XXX')+Replicate(' ', 30), 30)
+ LEFT(Isnull(CLIENT.mlis_client_state, '')+Replicate(' ', 15), 15)
+ LEFT(Isnull(CLIENT.mlis_client_zipcode, 'XXX')+Replicate(' ', 10), 10)
+ LEFT(' '+Replicate(' ', 20), 20)
+ LEFT(' '+Replicate(' ', 9), 9)
+ LEFT(' '+Replicate(' ', 7), 7)
+ LEFT(' '+Replicate(' ', 3), 3)
+ LEFT(' '+Replicate(' ', 1), 1)
+ LEFT('MILLENN'+Replicate(' ', 10), 10)
+ LEFT('1'+Replicate(' ', 1), 1)
+ LEFT('DrScrub'+Replicate(' ', 15), 15)
+ LEFT(' '+Replicate(' ', 10), 10)
+ LEFT(' '+Replicate(' ', 101), 101) PHYSICIAN_INFO
--+LEFT(' '+REPLICATE(' ',1),1)
FROM (SELECT DISTINCT mlis_practice_id,
requestor_npi,
requestor_first_name,
requestor_last_name
FROM complete
WHERE
Len(requestor_last_name) > 0
) MLIS
LEFT JOIN (SELECT *
FROM millennium_dw..d_physician
WHERE received_ims_information = 1) PHYSICIAN
ON MLIS.requestor_npi = Cast(PHYSICIAN.physician_npi AS
VARCHAR)
--we can remove this cast later
LEFT JOIN (SELECT *
FROM millennium_dw..d_client
WHERE rec_active_flg = 1) CLIENT
ON MLIS.mlis_practice_id = CLIENT.client_id
LEFT JOIN (SELECT DISTINCT T.mlis_client_address_1,
T.client_id,
LEFT(T.mlis_client_address_1, Isnull(
SplitAddresses.pos - 1,
2147483647))
Address1,
Substring(T.mlis_client_address_1,
SplitAddresses.pos + 1,
2147483647) Address2
FROM d_client T
OUTER apply (SELECT TOP 1 NULLIF(
Patindex(delimiter,
T.mlis_client_address_1), 0
) Pos
FROM
( VALUES ('% Suite %'),
('% Ste %'),
('% Bldg %'),
('% Building %'),
('%#%') ) SplitAddresses
(
delimiter)
WHERE T.mlis_client_address_1
LIKE
splitaddresses.delimiter
ORDER BY pos) SplitAddresses)
SplitAddresses
ON SplitAddresses.client_id = CLIENT.client_id
WHERE PHYSICIAN.physician_npi IS NULL
AND CLIENT.received_mlis_information = 1
AND LEN(address1)>0
AND LEN(CLIENT.mlis_client_state)>0
AND address1!='NO ADDRESS'
)
--AND MLIS.REQUESTOR_NPI IS NOT NULL)
SELECT *
FROM cte_biggie