21,886
社区成员
发帖
与我相关
我的任务
分享
$count_month=0;
$sql_login_month_last='select distinct pid from login_log where date<=last_day(date_add("'.$thisdate.'",interval -2 month)) and date>=DATE_FORMAT(concat(extract(year_month from date_add("'.$thisdate.'",interval -2 MONTH)),"'."01".'"),"'."%Y-%m-%d".'") and serverid='.$server;
$res_login_month_last=$dbhelper->Excute($sql_login_month_last);
while($row_login_month_last=mysql_fetch_array($res_login_month_last))
{
$sql_login_month='select count(distinct pid) as count from login_log where date<=last_day(date_add("'.$thisdate.'",interval -1 month)) and date>=DATE_FORMAT(concat(extract(year_month from date_add("'.$thisdate.'",interval -1 MONTH)),"'."01".'"),"'."%Y-%m-%d".'") and pid="'.$row_login_month_last['pid'].'"';
$res_login_month=$dbhelper->Excute($sql_login_month);
$rowcount_login_month=mysql_fetch_array($res_login_month);
if($rowcount_login_month['count']>0)
{
$count_month+=1;
}
}
select count(pid) as ct,DATE_FORMAT(date, '%x%v') as dt from table where date>="starttime" and date<="endtime" group by dt,pid having ct>=3
select count(pid) as counter ,pid
from
(select DISTINCT pid ,date from table where date<='2011-06-26' and date>='2011-06-20' ) tmp
group by pid
having counter >= 3
select count(pid) as count,date
from
(select DISTINCT pid ,date from table where date<='2011-06-20' and date>='2011-06-26' ) tmp
group by date
having count >= 3