0
を問い合わせます。は、私は次のような構造を持つテーブルと呼ばれる結果を持って
タスクテーブルに基づいて、ビューを作成し、その結果カラム(50のカットオフ値を有する)の統計を計算し、ビューに別の列にそれらを追加することです。
Iの結果のために特定の統計の計算を行い、記憶された関数作成した:
FUNCTION `calc_stat`(student INT, test INT, res INT) RETURNS float
BEGIN
declare tests INT;
declare totaltestamount INT unsigned DEFAULT 35;
declare weighted_res FLOAT;
declare maxres INT;
select max(result) into maxres
from results
where results.id_student = student;
select count(*) into tests
from results
where results.id_test = test;
set weighted_res = res/maxres*tests/totaltestamount;
return weighted_res;
END
と同様にビュー:
create view `statistics` as
select `id_test` AS `id_test`, `id_student` AS `id_student`, `result` AS `result`,calc_stat(`id_student`, `id_test`,`result`) AS `statistics`
from `results`
Iがない部分のみを、取得されるカットオフ値は、わからないので、結果が50以上のテーブルを取得する方法と、取得したビューに基づいて関数を適用するだけです。これを実行する方法はありますか?
明確な何かのres <50そして セットweighted_res = 0 //または何か エンド – sebas0205
もしあれば。そして、私はそれを知っているが、私が望むのは> 50で結果を取得し、それが全体のテーブル(その半分ではない)であることを考慮して、検索結果に関数を適用することです。 – Cap
結果が50未満の場合、ビューの「統計」列に表示する内容は? – sebas0205