2017-09-22 6 views
0

私はcc列を数える必要があります。その結果、これは2行のみで行われます。 最初の行。 premio_id = 0と の2番目の行を持つ人の数、premio_idが0と異なる人の数。すべてに感謝します。MYSQLは二重条件で計算します

シミュレーションの結果。

| quantity_people | premio type  | 
| 3000   |  0   | 
| 25231  | different to 0 | 

表:

table data

答えて

0

はこれを試してみてください:

select sum(cc) as quantity_people, 
(case premio_id when 0 then '0' else 'different to 0' end) as premio_type 
from your_table_name 
group by (case premio_id when 0 then '0' else 'different to 0' end); 
+0

あなたは、CC欄またはその中の値の合計の数が必要ですか? – roshan

+0

ありがとうございます。解決策は正しいです。 – zebaz