有人可以帮我把计数值合并在一起吗?
Select count(*) from swtickets
inner join swdepartments on swtickets.departmentid = swdepartments.departmentid
inner join swticketstatus on swtickets.ticketstatusid = swticketstatus.ticketstatusid
inner join swticketpriorities on swtickets.priorityid = swticketpriorities.priorityid
where
swdepartments.title = "XXX" and
swticketstatus.title = "Open"
上面输出一个有效的值,但是我们希望将更多的值分组到输出值中;你能帮助我们吗?
swticketstatus.title = "Open"
swticketstatus.title = "Driving Job"
swticketstatus.title = "Project Work"
swticketstatus.title = "Out of Hours"
答案 0 :(得分:0)
我希望你想要这个,
Select count(*) from swtickets
inner join swdepartments on swtickets.departmentid = swdepartments.departmentid
inner join swticketstatus on swtickets.ticketstatusid = swticketstatus.ticketstatusid
inner join swticketpriorities on swtickets.priorityid = swticketpriorities.priorityid
where
swdepartments.title = "XXX" and
(
swticketstatus.title = "Open"
OR
swticketstatus.title = "Driving Job"
OR
swticketstatus.title = "Project Work"
OR
swticketstatus.title = "Out of Hours"
)
如果不是OR
,您可以使用IN
Select count(*) from swtickets
inner join swdepartments on swtickets.departmentid = swdepartments.departmentid
inner join swticketstatus on swtickets.ticketstatusid = swticketstatus.ticketstatusid
inner join swticketpriorities on swtickets.priorityid = swticketpriorities.priorityid
where
swdepartments.title = "XXX"
and swticketstatus.title IN("Open","Driving Job","Project Work","Out of Hours")