Work with statistics December call records, statistics number dialed number, but the problem in a number can be dialed multiple times, each may or may not be connected, if the call Number Caller field group by group COUNT (*) after the number of statistics, This will cause can not see the statistics number of several are connected, a few are not connected, and then think of the Union is connected to the respective statistics, and then the statistical results in accordance with the number sorting together, the specific implementation of the following
billID (call log ID), caller (calling number), Callerstarttime (call time), Callerresult (dial result 0 not connected 1 on)
The SQL implementation statements are as follows:
as date, Callresult,count as num from ' Sup_tel_record ' where Callerstarttime > 1417363200 and Callerstarttime < 1420041600 and Callresult = 0 GROUP by Caller unionselect bill_idasdate, C Allresult,countasdate ASC
The output results are as follows:
Note When using Union for SQL statement Connections, the first SQL statement cannot be ordered by using order BY, or it will appear
MySQL Error 1221 incorrect usage of union and ORDER by
MySQL group statistics after the Order of the results (Union implementation)