WITH t AS (
SELECT
t.table_name,
LIST(
'SELECT ''' || t.table_name || ''' AS table_name, ORDERID, INTERNTIMESTAMP, COUNT(*) AS cnt' ||
' FROM ' || t.table_name ||
' GROUP BY ORDERID, INTERNTIMESTAMP' ||
' HAVING COUNT(*) > 1'
) AS q
FROM syscolumns c1
JOIN syscolumns c2
ON c1.table_id = c2.table_id
AND LOWER(c1.column_name) = 'orderid'
AND LOWER(c2.column_name) = 'interntimestamp'
JOIN systab t ON t.table_id = c1.table_id
WHERE t.creator = USER_ID() -- tables owned by current user
GROUP BY t.table_name
)
SELECT STRING (
LIST ( q, ' UNION ALL ' )
) AS generated_sql
FROM t;
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)