SQL查询:未获得正确的输出
我有下表,而不是零在添加天和删除天我想要尊重的输出 有人能帮我得到正确的SQL语句吗 我试了很多SQL查询:未获得正确的输出,sql,Sql,我有下表,而不是零在添加天和删除天我想要尊重的输出 有人能帮我得到正确的SQL语句吗 我试了很多 E_ID H_ID ADD_DAYS REMOVE_DAYS 1 1 "2" "0" 2 2 "4" "0" 2 2 "0" "1" 3 3 "2" "0" 3 3 "0" "4" 3 4 "0" "4" 实际的 E_ID H_ID ADD_DAYS REMOVE_DAYS 1 1 "2" "0" 2 2 "4" "0"
E_ID H_ID ADD_DAYS REMOVE_DAYS
1 1 "2" "0"
2 2 "4" "0"
2 2 "0" "1"
3 3 "2" "0"
3 3 "0" "4"
3 4 "0" "4"
实际的
E_ID H_ID ADD_DAYS REMOVE_DAYS
1 1 "2" "0"
2 2 "4" "0"
2 2 "0" "1"
3 3 "2" "0"
3 3 "0" "4"
3 4 "0" "4"
期望
E_ID H_ID ADD_DAYS REMOVE_DAYS
1 1 "2" "0"
2 2 "4" "1"
3 3 "2" "4"
3 4 "0" "4"
你可以在下面试试-
select e_id, h_id, max(ADD_DAYS),max(REMOVE_DAYS)
from tablename
group by e_id, h_id
你到底试过什么?您使用的是哪种DBMS产品?