Mysql案例陈述逻辑

时间:2015-01-08 12:27:32

标签: mysql

Complaint_status(id,complaint_id,updated_by,status_type,status_value)

2,0:Open   2,1:Pending   2,2:Closed

例如: 考虑由3个不同的用户(111,112,113)关闭3次投诉,尝试获得min(id)关闭,但不关闭111(在这种情况下为112)

另一个案例:投诉仅由111个用户关闭一次,其关闭时间应为curdate()

请建议在其他声明中做什么。

and cs.id IN(CASE WHEN (select MIN(id) from complaint3_status where complaint_id=c3.id and status_type=2 and status_value = 2) is null 
THEN (select MAX(id) from complaint3_status where complaint_id=c3.id and status_type=2)
ELSE
(
select MIN(id) from complaint3_status where complaint_id=c3.id and status_type=2 and status_value = 2
)
END)

0 个答案:

没有答案