Good morning, I also wrote stackoverflow to get help regarding the conversion of a query that I'm trying to execute, if I run it in phpmyadmin it works perfectly but when I convert it for Laravel I get errors, I tried to use two conversion tools also online but I get the same result can anyone help me resolve this error?
SELECT ticket,
SUM(MINUTE(time_stamp))
AS minutes,
SUM(MINUTE(time_stamp))/60
AS hours,
SUM(MINUTE(time_stamp))/(60*24)
AS days,
SUM(MINUTE(time_stamp))/(60*24*7)
AS week
FROM `tickets
GROUP BY ticket
$tickets = DB::table('tickets')
->select('ticket', "sum(minute(time_stamp)) as minutes", "sum(minute(time_stamp))/60 as hours", "sum(minute(time_stamp))/ (60*24) as days", "sum(minute(time_stamp))/ (60*24*7) as week")
->groupBy("ticket")
->get();
The error generated is this: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sum(minute(time_stamp))' in 'field list'
$tickets = DB::table('tickets') ->select('ticket', DB::raw("SUM(MINUTE(time_stamp)) as minute"), ("SUM(MINUTE(time_stamp)) as hours"), ("SUM(MINUTE(time_stamp)) as days"), ("SUM(MINUTE(time_stamp)) as week")) ->groupBy('ticket') ->get();
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'SUM(MINUTE(time_stamp))' in 'field list'