Does mySQL calculate one or more people?

Database query results:

clipboard.png

11 code ID 1 purchased 3 times
11 Legacy ID 2 purchased 10 times
on November 12th, ID 36 purchased once
on November 12th, ID 37 purchased once

SQL statement "$chartData"


countid
ID
FROM_UNIXTIMEadd_time"m /d"add_date
FROM user_order
GROUP BY id

? question question
my aim is to find out how many people "bought once" on that day throughout the month, and how many people bought it more than twice
is this sentence correct?
I wanted to throw it into Google"s chart, but I found that it didn"t seem right, and I couldn"t find the reason myself.

this is the format he wants.

data.addRows[
[1,37.8,80.8,41.8]
[2,30.9,69.5,32.4]
[3,25.4,57,25.7]
[4,11.7,18.8,10.5]
[5,11.9,17.6,10.4]
[6,8.8,13.6,7.7]
[7,7.6,12.3,9.6]
[8,12.3,29.2,10.6]
[9,16.9,42.9,14.8]
[10,12.8,30.9,11.6]
[11,5.3,7.9,4.7]
[12,6.6,8.4,5.2]
[13,4.8,6.3,3.6]
[14,1,4,6.2,3.4]
];

my PHP script

foreach$ chartData as $ key{
$ new = null;
$ old = null;
if$ key ["times"] == 1{
$ new + = 1;
$ old = 0;
} else {
$ new = 0;
$ old + = 1;
}

$ data [] = array
intsubstr$ key ["add_date"]3,2int$ newint$ old
;
}

the printed result is

[[11,0,1],[11,0,1],[12,1,0],[12,1,0]]

the first to print the date, the second is the number of people who only buy once, and the second is the number of people who buy more than twice.
it still feels strange. Do you have a train of thought?


until you encounter a problem, most people have the right way of thinking!
now I don't know what's wrong with you! Is the
written incorrectly by sql? Or the table doesn't show up?

      SELECT 
      count*as ``
      id
      date(add_date) as `add_date`
      FROM user_order
      GROUP BY id ,date(add_date)

this statistic is correct, and you should also include add_date
so that you will find that users with an id of 2 will not only buy 10 items on the 11th, but may also buy something else on the 12th.
secondly, when the table is displayed, the data should be

.
[
  [11,first_buy,secend_buy],
  [12,first_buy,secend_buy],
  [13,first_buy,secend_buy],
  [14,first_buy,secend_buy],
]

like this


feel that the date is taken as a condition, and then query the ID and the number of purchases will be more intuitive

SELECT id, times FROM table WHERE date = '2018-11-11' GROUP BY id
Menu