Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. SELECT * FROM
  2. information_schema.columns cl
  3. INNER JOIN
  4. information_schema.columns cr
  5. ON
  6. cl.table_name < cr.table_name AND
  7. cl.data_type = cr.data_type
  8.  
  9. SELECT
  10. REPLACE(REPLACE(REPLACE(REPLACE(
  11. 'SELECT ''{Ltable}.{Lcol}'' as lefty, ''{Rtable}.{Rcol}'' as righty, count(l.{Lcol}) as countLefty, count(r.{Rcol}) as countRighty, case when count(r.{Rcol}) = 0 then 0 else count(l.{Lcol})/count(r.{Rcol}) end as percenty
  12. FROM {Ltable} l LEFT JOIN {Rtable} r ON l.{Lcol} = r.{Rcol} UNION ALL',
  13. '{Ltable}', cl.table_name),
  14. '{Rtable}', cr.table_name),
  15. '{Lcol}', cl.column_name),
  16. '{Rcol}', cr.column_name)
  17. FROM
  18. information_schema.columns cl
  19. INNER JOIN
  20. information_schema.columns cr
  21. ON
  22. cl.table_name < cr.table_name AND
  23. cl.data_type = cr.data_type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement