I will ask you. in sql i have a code like this ?
SELECT keterangan_warga, COUNT(keterangan_warga) as cnt
FROM ( SELECT distinct nokk_warga, keterangan_warga FROM `warga` ) as t
GROUP by keterangan_warga;
then , i will perform this to Laravels. How can I do? Thanks, I try to 2 select but it error.
i will perform this data t laravels like this
and I try to implement in laravels there is error intelephense in the second select and second from
$data = DB::selectRaw('keterangan_warga , count(keterangan_warga ) as JumlahWarga')
->from( select('nokk_warga', 'keterangan_warga')->distinct()->from('warga'))
->groupby('keterangan_warga')
->get();
The table name is warga, and this is the table. enter image description here
I will count keterangan_warga based on nokk_warga, i already successfully show the data that I need in sql but I dont know how to perform it in laravales. Do you have any suggestion?