-1
1人のレコードにつき複数のアラートレコード(1人につき最大10個)を表示するにはどうすればよいですか?行番号を使用してレコードに番号を付けて出力に配置しようとしていますが、クロス・ステートメントの「where」パラメータに誤った構文エラーがあるため、書いたコードは機能しません。私は必要なものを達成するために複数の方法を試しましたが、エラーを乗り越えることはできません。助けてください。行番号を使用して複数のレコードを結合する方法
select
sd.[student_number],
a.[health_alert],
a.[comments],
b.[health_alert],
b.[comments]
from student_enrollmentcube as se,
student_demographicscube as sd
cross apply (select a.[health_alert], a.[comments], (select row_number()
over (partition by a.[student_id] order by a.[student_id]) as r1 from
ar_student_health_alerts) a) where a.[student_id] = sd.[student_id] and
r1 = 1)
cross apply (select b.[health_alert], b.[comments], (select row_number()
over (partition by b.[student_id] order by b.[student_id]) as r2 from
ar_student_health_alerts) b) where b.[student_id] = sd.[student_id] and
r2 = 2)
where se.student_id = sd.student_id and
se.enrollment_status= 'active' and
se.[current_academic_year] = 'y'
これはSQLに関連していますか?その場合は、適切にタグを付けてください。 – genpfault
正確なエラーメッセージも含めてください –