Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 16th, 2012  |  syntax: SQL  |  size: 1.12 KB  |  hits: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SELECT
  2.           fdfdi.field_district_id_value AS district_id
  3.         , YEAR
  4.         , race
  5.         , ROUND(SUM(COUNT) / inner_sum * 100 ,2) AS percent
  6. FROM
  7.         school_data_race_ethnicity_raw sdre
  8.         INNER JOIN field_data_field_school_id fdfsi ON fdfsi.field_school_id_value = sdre.school_id
  9.         INNER JOIN field_data_field_district fdfd ON fdfd.entity_id = fdfsi.entity_id
  10.         INNER JOIN field_data_field_district_id fdfdi ON fdfd.field_district_nid = fdfdi.entity_id
  11.         INNER JOIN
  12.         (
  13.                 SELECT fdfdi_inner.field_district_id_value, sdre_inner.YEAR, SUM(COUNT) AS inner_sum
  14.                 FROM
  15.                         school_data_race_ethnicity_raw AS sdre_inner
  16.                         INNER JOIN field_data_field_school_id AS fdfsi_inner ON fdfsi_inner.field_school_id_value = sdre_inner.school_id
  17.                         INNER JOIN field_data_field_district AS fdfd_inner ON fdfd_inner.entity_id = fdfsi_inner.entity_id
  18.                         INNER JOIN field_data_field_district_id AS fdfdi_inner ON fdfd_inner.field_district_nid = fdfdi_inner.entity_id
  19.                 GROUP BY fdfdi_inner.field_district_id_value, sdre_inner.YEAR
  20.         ) INNER ON
  21.                 INNER.field_district_id_value = fdfdi.field_district_id_value
  22.                 AND INNER.YEAR = sdre.YEAR
  23. GROUP BY district_id, YEAR, race