sql - MySQL - Filter records which date is biggest -


i have mysql select query:

select s.*  campaign_statistic s inner join campaign c on s.campaign_id = c.campaign_id  c.campaign_id = 51  , date(s.created_date) between date(c.start_date) , date(c.end_date) 

and getting result:

id  campaign_id     instagram_id    media_id                        has_tag     comments_count  likes_count     created_date            status **  ***********     ************    ****************************    ********    *************   ***********     *******************     ****** 1   51              1230544324      957801995790641919_1230544324      1               16              2015-11-01 13:10:29     1 2   51              1230544324      957799073015065299_1230544324      2               11              2015-11-01 13:10:29     1 3   51              1230544324      957790310736521811_1230544324      5               20              2015-11-01 13:10:29     1 4   51              1230544324      957801995790641919_1230544324      1               16              2015-11-02 13:10:29     1 5   51              1230544324      957799073015065299_1230544324      2               11              2015-11-02 13:10:29     1 6   51              1230544324      957790310736521811_1230544324      5               20              2015-11-02 13:10:29     1 7   51              1230544324      957801995790641919_1230544324      1               16              2015-11-03 13:10:29     1 8   51              1230544324      957799073015065299_1230544324      2               11              2015-11-03 13:10:29     1 9   51              1230544324      957790310736521811_1230544324      5               20              2015-11-03 13:10:29     1 

but trying records created_date biggest above result , biggest created_date 2015-11-03.

i need result:

id  campaign_id     instagram_id    media_id                        has_tag     comments_count  likes_count     created_date            status **  ***********     ************    ****************************    ********    *************   ***********     *******************     ****** 7   51              1230544324      957801995790641919_1230544324      1               16              2015-11-03 13:10:29     1 8   51              1230544324      957799073015065299_1230544324      2               11              2015-11-03 13:10:29     1 9   51              1230544324      957790310736521811_1230544324      5               20              2015-11-03 13:10:29     1 

any idea or suggestion?

thanks.

could try running this:

select s.*  campaign_statistic s inner join campaign c on s.campaign_id = c.campaign_id  c.campaign_id = 51  , date(s.created_date) between date(c.start_date) , date(c.end_date)     , date(s.created_date) = (     select date(max(s.created_date))  campaign_statistic s inner join campaign c on s.campaign_id = c.campaign_id  c.campaign_id = 51  , date(s.created_date) between date(c.start_date) , date(c.end_date)) 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -