All pastes #946485 Raw Edit

Someone

public sql v1 · immutable
·published 2008-03-17 19:10 UTC
rendered paste body
with A as (	select	table_name, 			column_name	from	information_schema.columns	where	table_name in ('claim_header', 'claim_charge')), B as (	select	table_name = replace(table_name, 'up_837_', ''),			column_name	from	information_schema.columns b	where	table_name like 'up_837_%'		and	replace(table_name, 'up_837_', '') in (select table_name from A)), Compared as (	select	table_name = coalesce(a.table_name, b.table_name),			column_name = coalesce(a.column_name, b.column_name),			in_a = case when a.table_name is not null then 1 else 0 end,			in_b = case when b.table_name is not null then 1 else 0 end	from	A	full outer join B on a.table_name = b.table_name and a.column_name = b.column_name)select	*from	Comparedorder by table_name, in_a + in_b desc, in_a