【发布时间】:2017-11-17 06:33:30
【问题描述】:
我在 Oracle 数据库中有如下数据
Name Session CATEGORY HT WT BMI
John SESSION 1 OW 1.5 64.6 28.71
John SESSION 3 OW 1.5 64.6 28.71
Eric SESSION 1 OW 1.48 55.7 25.43
Eric SESSION 3 OW 1.52 55.4 23.98
我已经使用 pivot 像这样转换了上述数据
Name session_1_Category Session_1_height session_1_weight session_1_BMI session_3_Category Session_3_height session_3_weight session_3_BMI
John OW 1.5 64.6 28.71 OW 1.5 64.6 28.71
Eric OW 1.48 55.7 25.43 OW 1.52 55.4 23.98
我想比较第 1 课的身高和第 3 课的身高,以及第 1 课的体重和第 3 课的体重。
例如
if SESSION_1_HEIGHT =SESSION_3_HEIGHT then height_status=true else height_status=false
if SESSION_1_WEIGHT =SESSION_3_WEIGHT then weight_status=true else weight_status=false
if SESSION_1_BMI =SESSION_3_BMI then bmi_status=true else bmi_status=false
请看这里SQLFiddle
【问题讨论】:
标签: sql oracle comparison pivot rows