sql >> Database teknologi >  >> RDS >> Mysql

MySQL LEFT JOIN med GROUP BY og WHERE IN (underforespørgsel)

SELECT  a.date, COUNT(b.campaignid) totalStat
FROM    campaigndata a
        LEFT JOIN campaignfilter b
            ON  a.campaignid = b.campaignid AND
                b.campaigntype = 1
GROUP   BY a.date

For yderligere at få mere viden om tilmeldinger, besøg venligst nedenstående link:

OPDATERING 1

SELECT  a.date, 
        COALESCE(b.totals,0) totals
FROM    demo_calendar a
        LEFT JOIN
        (
            SELECT  a.date, SUM(impressions) totals
            FROM    demo_campaigndata a
                    INNER JOIN demo_campaignfilter b
                        ON a.campaignid = b.campaignid
            WHERE   b.campaigntype = 1
            GROUP   BY a.date
        ) b ON a.date = b.date



  1. Parallelisme kommer til VAKUUM

  2. MySQL:Curdate() vs Now()

  3. Valgfri parametre i Mysql-lagrede procedurer

  4. Hierarkisk liste over triggerhændelsestyper i SQL Server 2017