sai reddy

sai reddy

  • NA
  • 18
  • 6.8k

Self join on three columns with conditions

Sep 7 2017 9:52 PM
------This is my query from a single table name called mis_subscription_details
 
SELECT DISTINCT DATE(created_timestamp) AS DATE,(
SELECT COUNT(*) FROM mis_subscription_details WHERE vastype='rrbt' AND DATE(created_timestamp)=DATE_SUB(CURDATE(), INTERVAL 6 DAY)
) AS Total_Subscription
,
(
SELECT COUNT(*) FROM mis_subscription_details WHERE vastype='RRBTChild' AND DATE(created_timestamp)=DATE_SUB(CURDATE(), INTERVAL 6 DAY)
) AS Total_Tone_Download_New
FROM mis_subscription_details WHERE DATE(created_timestamp)=DATE_SUB(CURDATE(), INTERVAL 7 DAY)
 
 
----From the above query i need three columns such as Date, Total_Subscription,Total_Tone_Download_New   with joins

Answers (5)