1
我有表STREAMS:MySQL的統計重複行的值和不顯示重複的行名
+----+----------+-------------------------------------------------------------+-------------+-------------+
| id | name | stream | server | bouquet |
+----+----------+-------------------------------------------------------------+-------------+-------------+
| 1 | HOME | ["http://ur11.com/", "http://ur12.com/"] | ["1", "3"] | ["3","2"] |
| 2 | HOME | ["http://ur15.com/", "http://ur16.com/"] | ["12", "13"] | ["31","12"] |
+----+----------+-------------------------------------------------------------+-------------+-------------+
我有表看:
+----+--------+------------+---------+
| id | stream | month | watched |
+----+--------+------------+---------+
| 16 | 2 | 2017-02-01 | 1 |
| 2 | 1 | 2017-01-01 | 3 |
| 15 | 2 | 2017-01-01 | 4 |
+----+--------+------------+---------+
,需要從查詢中得到這樣的:
+--------+------------+---------+
| stream | month | watched |
+--------+------------+---------+
| 2 | 2017-02-01 | 5 |
| 1 | 2017-01-01 | 3 |
+--------+------------+---------+
我嘗試使用:
SELECT DISTINCT stream, month, watched FROM watched;
這個顯示全部沒有重複,但如何統計相同的流和顯示在監視?在例子中,你看到我們有2 - 1觀看流和2 - 4觀看流...我需要加在一起(1 + 4),並在表流2中顯示 - 看着5 ..但我只得到第一流清晰..我嘗試計數,但它顯示我重複....我需要組?
是......那就是......你是天才......感謝......我會在6分鐘內接受答案......而我即時嘗試在小時內得到這個只用組和計數..我發現我做錯了..謝謝 – John