General SQL Parser is a Java/.NET library. It provides a rich set of APIs to parse, decode, analyze and rewrite SQL scripts. Supports more than 10 major database platforms. This repo provides demos and testcases to help people make better use of the General SQL Parser
CREATE VIEW LADEHISTORIE_V
AS
SELECT
objekt, datum, endgueltigflag, zeitstempel
FROM
(
SELECT
'Programm' AS objekt
, r.datum
, MAX(s.endgueltigflag) AS endgueltigflag
, MAX(r.load_timestamp) AS zeitstempel
FROM dm_mediafacts.reichweite_v r
JOIN dm_mediafacts.sendeprotokoll_v s
ON r.p_hk = s.p_hk
GROUP BY 1, 2
UNION
SELECT
'Tagesmarktanteil' AS objekt
, datum
, MAX(endgueltigflag) AS endgueltigflag
, MAX(load_timestamp) AS zeitstempel
FROM dm_mediafacts.ganztag_v
GROUP BY 1, 2
UNION
SELECT
'5-Minuten' AS objekt
, datum
, MAX(endgueltigflag) AS endgueltigflag
, MAX(load_timestamp) AS zeitstempel
FROM dm_mediafacts.intervall5_v
GROUP BY 1, 2
) t
;
CREATE VIEW ganztag_v
AS
SELECT
CAST(s_tg.videoscope_date AS DATE) AS DATUM
, s_mf.sender_id AS SENDER_ID
, s_zg.zielgruppe_id AS ZIELGRUPPE_ID
, s_tg.sehbeteiligung_mio AS SEHB_MIO
, s_tg.sehbeteiligung_tvgesamt_mio AS SEHB_FSGES_MIO
, s_tg.marktanteil AS MARKTANTEIL
, s_stis.ist_endgueltig AS ENDGUELTIGFLAG
, GREATEST(
s_tg.load_timestamp
, s_mf.load_timestamp
, s_zg.load_timestamp
) AS LOAD_TIMESTAMP
FROM raw_vault.s_slotmessungen_tagesslot s_tg
JOIN raw_vault.l_slotmessungen_sender l_sms
ON s_tg.h_slotmessungen_hk = l_sms.h_slotmessungen_hk
JOIN raw_vault.l_zielgruppe_slotmessungen l_zs
ON s_tg.h_slotmessungen_hk = l_zs.h_slotmessungen_hk
JOIN business_vault.s_slotmessungen_tagesslot_bv_ist_endgueltig s_stis
ON s_tg.h_slotmessungen_hk = s_stis.h_slotmessungen_hk
JOIN raw_vault.s_sender_mf s_mf
ON l_sms.h_sender_hk = s_mf.h_sender_hk
AND s_mf.is_deleted = FALSE
AND s_mf.delivery_end_timestamp = '9999-12-31 00:00:00.0'
JOIN raw_vault.s_zielgruppe_mf s_zg
ON l_zs.h_zielgruppe_hk = s_zg.h_zielgruppe_hk
AND s_zg.is_deleted = FALSE
AND s_zg.delivery_end_timestamp = '9999-12-31 00:00:00.0'
WHERE s_tg.is_deleted = FALSE
AND s_tg.delivery_end_timestamp = '9999-12-31 00:00:00.0'
Oracle sample SQL:
https://github.com/sqlparser/gsp_demo/tree/master/java/src/demos/columnAnalyze