Guest User

Untitled

a guest
May 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.83 KB | None | 0 0
  1.         SELECT
  2.     [cardholder_index] ,
  3.                 CASE WHEN sex = 'M' THEN 1
  4.                      WHEN sex = 'F' THEN 2
  5.                      WHEN sex = 'U' THEN 0
  6.                      ELSE sex
  7.                 END AS sex,
  8.                 [group_month],
  9.                 [group_year],
  10.                 drinks_per_week,
  11.                 feel_stop_drinking,
  12.                 annoyed_by_criticizing_drinking,
  13.                 felt_bad_about_drinking,
  14.                 consider_overall_health,
  15.                 arthritis,
  16.                 asthma,
  17.                 bronchitis_emphysema,
  18.                 chd_chf_heart_attack,
  19.                 diabetes,
  20.                 high_blood_pressure,
  21.                 high_cholesterol,
  22.                 obesity,
  23.                 often_eat_out,
  24.                 comfortable_with_eating_habits,
  25.                 high_fat_foods,
  26.                 fried_foods,
  27.                 take_steps_to_maintain_weight,
  28.                 activity_30_minute_per_week,
  29.                 hours_exercise_per_day,
  30.                 satisifed_with_exercise,
  31.                 activity_30_minutes_4_or_more_per_week,
  32.                 felt_depressed,
  33.                 smoke,
  34.                 other_tobacco_products,
  35.                 spend_time_with_smokers
  36.         FROM    [healthreach_master].[dbo].[tbl_hra_import] t
  37.         WHERE t.group_year = 2011 AND    employer_group IN (
  38.                 SELECT  VALUE
  39.                 FROM    dbo.funcListToTable(N'1,2,3', ',') )
  40.                 AND hra_id = ( SELECT   MAX(hra_id)
  41.                                FROM     tbl_hra_import
  42.                                WHERE    cardholder_index = t.cardholder_index
  43.                                         AND SOURCE = 'file'
  44.                                         AND group_year = 2011
  45.                              )
  46.         ORDER BY cardholder_index
Add Comment
Please, Sign In to add comment