分析 MySQL DB 中的电话记录

发布于 2024-07-29 19:00:42 字数 575 浏览 7 评论 0原文

上次我在这里问问题时,我得到了很多关于如何解决特定问题的好主意。 就像我上次解释的那样,编程只是我喜欢做的事情,但它不是我在学校学过的东西,所以我没有正确的做事方法。 我是一名电气工程师,正在经济衰退中挣扎,到处做一些编程工作。

目前我在一家做VoIP 的公司工作。 他们购买的软件缺乏其他系统所具有的许多重要功能,因此我决定开始构建一些工具来完成这些缺失的事情。

我认为非常重要的事情之一是找出特定给定时间内呼叫的最大负载(同时呼叫的最大数量)。 例如,我想知道 8 月 3 日的最大同时通话数。

现在,对我来说幸运的是,该软件将所有信息存储在 MySQL 数据库中,因此我有一个表,其中包含自系统首次开始运行以来的所有调用。

“Calls”表有 2 个文件,名为“call_start”和“call end”,它们的类型为“datetime”。

根据这些信息,我想弄清楚如何查询数据库并找出在我指定的时间范围内同时活动呼叫的最高数量是多少。

我主要使用 C#,因此使用 C# 的想法将受到欢迎。 我不确定它是否可以专门在 MySQL 中完成,但这也可以。

感谢大家的帮助。

Last time I asked a question here, I got tons of great ideas on how to solve a particular problem. Like I explained last time, programming is just something I love to do, but it's not something I studied in school, so I have no proper methods of doing things. I'm an Electrical Engineer struggling through a recession doing some programming gigs here and there.

Currently I'm working for a company doing VoIP. The software they bought lacks in many important features other system have, so I decided to start building a few tools that will allow me to do these missing things.

One of the things I consider to be very important is finding out the MAX LOAD of CALLS in a particular given time (maximum number of simultaneous calls). For example, I want to know the maximum simultaneous phone calls on August 3rd.

Now, luckyly for me, this software stores all it's information on a MySQL database, so I have a table with ALL the calls since the system first started running.

The "Calls" table has 2 files called "call_start" and "call end", and they are type "datetime".

Based on this information, I would like to figure out how I could query the database and find out what was the highest number of active calls simultaneously in a time frame specified by me.

I'm working with C# mostly, so ideas using C# would be welcomed. I'm not sure if it could be done exclusively in MySQL, but that would also work.

Thanks everyone for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝天白云 2024-08-05 19:00:43

这不是最有效的方法,但这将为您提供每小时(今天)的计数,包括该小时内开始和结束的所有呼叫。

select hour(call_start),count(*) from calls 
where call_end <= hour(call_start) and date(call_start) = date(now())
group by hour(call_start);

Not the most efficient way to do it, but this will give you a count per hour (for today), including all calls that start and end within that hour.

select hour(call_start),count(*) from calls 
where call_end <= hour(call_start) and date(call_start) = date(now())
group by hour(call_start);
琉璃繁缕 2024-08-05 19:00:42

前段时间SO上也有人提出过类似的问题,你看一下:
查找 SQL 记录中的并发用户数< /a>

我希望这也适用于 Mysql。

There was a similar question posed on SO a while ago, take a look:
Find number of concurrent users in a SQL records

I hope this works on Mysql too.

相思故 2024-08-05 19:00:42

我查看了类似问题并没有看到一个简单的答案。 基本上,您想知道每次通话开始时有多少个通话。 以下内容可行

create temporary table starts (call_started time);
insert into starts select distinct call_started from calls;

select starts.call_started, count(*)
  from starts, calls
  where starts.call_started >= calls.call_started and starts.call_started <= calls.call_ended
  group by starts.call_started
  order by count(*) desc;

如果您只想要最大负载,则 ,只需将“LIMIT 1”添加到最终查询即可。 如果您想用图表显示结果,只需按开始时间排序即可。

I looked at the similar question and didn't see a simple answer. Basically, you want to know how many calls there are every time a call starts. The following would work

create temporary table starts (call_started time);
insert into starts select distinct call_started from calls;

select starts.call_started, count(*)
  from starts, calls
  where starts.call_started >= calls.call_started and starts.call_started <= calls.call_ended
  group by starts.call_started
  order by count(*) desc;

If you only wanted the max load, just add "LIMIT 1" to the final query. If you want to graph the results, just sort by start time instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文