简体   繁体   English

每天获取平均上传次数(或其他)

[英]Getting average number of uploads (or something else) per day

Sorry if I'm using the wrong SE network for this question. 抱歉,如果我为此问题使用了错误的SE网络。

I'm in need of fetching the average number of uploads and registrations to my website per day. 我每天需要获取平均上传和注册到我的网站的数量。 The problem is that I can't seem to figure out the math for this task. 问题是我似乎无法弄清楚该任务的数学原理。 In my database tables for uploads and registrations, I have columns which indicate when the row was created, which stores an UNIX timestamp. 在用于上载和注册的数据库表中,我有一些列,指示创建行的时间,该行存储UNIX时间戳。

How would I calculate the average number of rows created per day? 如何计算每天创建的平均行数?

select avg(anz) from (
    select
    date(from_unixtime(your_TS_column)) as my_date,
    count(*) as anz
    from
    your_table
    group by my_date
) subquery_alias

您可以找到行数并按上传天数进行过滤,我认为您的查询应该是这样,

Select count(*) no_of_uploads FROM UPLOAD_TABLE_NAME WHERE 1 AND OTHER_CONDITIONS GROUP BY DAY(UPLOAD_DATE)

you can try to see how many record in your table and divide the number by the cont of the days the code will be 您可以尝试查看表中有多少条记录,然后将其除以代码的有效天数

$q=mysql_query("SELECT * FROM `your_table`;");
$n=mysql_num_rows($q);


$d=mysql_query("SELECT * FROM `your_table` GROUP BY DATE(`date_column`);");
$m=mysql_num_rows($d);
echo ($n/$m);

Some very random answers here with no explanation. 一些非常随机的答案,没有任何解释。 So to answer your question it seems like you need the maths for average uploads and average registrations? 因此,回答您的问题似乎需要平均上载次数和平均注册人数的数学运算?

You will need first day, total registrations and total uploads. 您将需要第一天,总注册和总上传量。 $total_uploads and $total_registrations needs to be fetched from database 需要从数据库中获取$ total_uploads和$ total_registrations

$first_day = strtotime("01-01-2013"); //if you want to average from the first of january 2013
$time = time(); //current time

$total_days = ($time - $first_day) / 60 / 60 / 24; //gives you total days
$average_registrations = $total_registrations / $total_days;
$average_uploads = $total_uploads / $total_days;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM