mardi 2 juin 2020

Laravel Join with 2 GroupBy

can you help me solve this problem?

I want to combine the two tables

transaction_ppob transaction_sosmed

In the table there is a column containing the status, I want to count the amount success, wait, and error in table 1 and table 2

Here is the code

$status = DB::table('transaction_ppob as ppob')
    ->join('transaction_sosmed as sosmed','ppob.user_id', '=', 'sosmed.user_id')
    ->select('sosmed.status', 'ppob.status', DB::raw('count(*) as total'))
    ->groupByRaw('sosmed.status, ppob.status')
    ->get();

How do you calculate the second column?

transaction_ppob

  • success
  • success
  • pending

transaction_sosmed

  • pending
  • error


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire