0

私はこのようなmysqlテーブルを使用しています:

|  userid  |  regdate   | question  | answer  |
-----------------------------------------------
      1      2010-10-14   question 1  answer1
      2      2010-10-14   question 2  answer2    
      3      2010-10-15   question 3  answer3
      4      2010-10-16   question 4  answer4

1 日あたりの登録ユーザー数と、1 日あたりに送信された質問と回答の数をカウントしたいと考えています。1 つの mysql クエリでそれを行うことはできますか?

結果は次のようになります。

|  regdate  |  new users  |  questions sent  | answers sent  |
--------------------------------------------------------------
 2010-10-14        2               2                 2
 2010-10-15        1               1                 1
 2010-10-16        1               1                 1
4

2 に答える 2

0

多分:

SELECT regadte, 
       COUNT(userid) as new_users, 
       COUNT(question) as questions_sent, 
       COUNT(answer) as answers_sent 
FROM table 
GROUP BY regdate;

「新規登録ユーザー」なのか「ログインユーザー」なのかよくわかりません。また、あなたのテーブルから、ユーザーは質問ごとに回答を送信する必要があるように見えますが、そうではないと思います...

于 2010-10-17T16:58:57.423 に答える
0

これを試して

regdate、count(userid) を new_users として、count(question) を question_sent として、count(answer) を answer_sent として選択します。
regdate による table_name グループから
于 2010-10-17T16:59:27.067 に答える