0

1 つのテーブル t_push_member に 2 つのクエリがあります

SELECT
  DATE_FORMAT(`member_subscribe_at`, '%d-%m-%y') Tanggal,
  count(`member_msisdn`) 'total_reg'
FROM
  `t_push_member` 
WHERE
  `service_keycode`='nocan' 
GROUP BY
  Tanggal,
  'total_reg'
ORDER BY
  Tanggal

SELECT
  DATE_FORMAT(`member_unsubscribe_at`, '%d-%m-%Y') Tanggal,
  COUNT(`member_msisdn`) 'total_unreg'
FROM
  `t_push_member` 
WHERE
  `service_keycode`='nocan'
GROUP BY
  Tanggal, 'total_unreg'
ORDER BY
  Tanggal

2 つのクエリを 1 つのクエリにする方法

4

2 に答える 2

1
select * 
from 
( SELECT DATE_FORMAT(member_subscribe_at, '%d-%m-%y') Tanggal, count(member_msisdn),'REG' as Registered FROM t_push_member 
    where service_keycode='nocan' 
    group by Tanggal  

    UNION

    SELECT DATE_FORMAT(member_unsubscribe_at, '%d-%m-%Y') Tanggal, count(member_msisdn),'NOT_REG' as Registered FROM t_push_member 
    where service_keycode='nocan'
    group by Tanggal
)
order by  Tanggal

UNION の詳細については、http://www.w3schools.com/sql/sql_union.aspを参照してください。

于 2013-05-13T10:57:21.483 に答える
0

2つの間の「結合」を使用 - との代わりに

于 2013-05-13T10:56:24.343 に答える