nyk0r

My Indentation Style

Jul 15th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.86 KB | None | 0 0
  1. SELECT
  2.     CAST (COUNT(DISTINCT our.unique_id) AS FLOAT) / (SELECT COUNT(*) FROM our_Schools) * 100
  3. FROM
  4.     -- Our Schools
  5.     (SELECT
  6.         REPLACE(LOWER(st.abbr + sc.city + sc.district + sc.name), ' ', '') AS unique_id
  7.     FROM
  8.         dbo.our_Schools sc
  9.         INNER JOIN States st
  10.             ON sc.state = st.fips) our
  11.     INNER HASH JOIN
  12.     -- GS
  13.     (SELECT DISTINCT
  14.         REPLACE(LOWER(st.abbr + e.city + e.district_name + e.name), ' ', '') AS unique_id,
  15.         e.universal_id
  16.      FROM
  17.         dbo.GS_Entities e
  18.         INNER JOIN States st
  19.             ON e.state_id = st.fips
  20.      WHERE
  21.         e.entity_id = 3 /* schools */) gs
  22.         ON our.unique_id = gs.unique_id
  23.     INNER JOIN dbo.GS_Census c
  24.         ON gs.universal_id = c.universal_id
  25.         AND c.data_type_id = 2 -- enrollment
  26.         AND CAST(c.value AS INTEGER) < 600
Advertisement
Add Comment
Please, Sign In to add comment