I have table requests
with fields
`id` `user_id` `status` `url` `price` `date`
and table people
with fields
`id` `name` `number` `password` `nickname`
I am trying to group all requests by each date and count how many request is in each day with this query:
$data['dates'] = RequestModel::orderBy('date', 'desc')
->groupBy(DB::raw("DATE_FORMAT(date, '%Y-%m-%d')"))
->take(2)
->get(array(
DB::raw('Date(date) as date'),
DB::raw('COUNT(*) as requests'),
));
this gives data like this:
"dates": [
{
"date": "2018-06-13",
"requests": 230
},
{
"date": "2018-06-12",
"requests": 399
}]
The problem is that when user creates new request in people
table is creating new user with same number
and distinct nickname
. like this:
`id` `name` `number` `password` `nickname`
1 jack 555845 pass 555845-1
1 jack 555845 pass 555845-2
I want to count requests with distinct user numbers and don't know how to do it. help me if you can
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire