need sql query output like this - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: need sql query output like this (/showthread.php?tid=71896) |
need sql query output like this - kvanaraj - 10-05-2018 my table look like Code: Id time_stamp Code: output should be Code: SELECT date(time_stamp) as time_stamp, need suggestion . RE: need sql query output like this - jreklund - 10-06-2018 This should do it. Code: SELECT temp_time as time_stamp, SUM(AM) as FN, SUM(PM) as AN, count(temp_time) AS `count` FROM (SELECT DATE_FORMAT(`time_stamp`,'%d-%m-%Y') AS temp_time, DATE_FORMAT(`time_stamp`,'%p') AS AM_PM, IF((SELECT AM_PM)='AM',1,0) AS AM, IF((SELECT AM_PM)='PM',1,0) AS PM FROM `date_time`) AS FAKE_TABLE_NAME GROUP BY time_stamp |