select sum(Case When status = 0 And Weigh Is Not Null Then 1 Else 0 End) As CountStatus0,
sum(Case When status = 0 Then Weigh Else Null End) As SumStatus0,
sum(Case When status = 2 And Weigh Is Not Null Then 1 Else 0 End) As CountStatus2,
sum(Case When status = 2 Then Weigh Else Null End) As SumStatus2,
sum(Case When status = 3 And Weigh Is Not Null Then 1 Else 0 End) As CountStatus3,
sum(Case When status = 3 Then Weigh Else Null End) As SumStatus3
from myTable where id=120 and status In (0, 2, 3)
Tom
No comments:
Post a Comment