Reputation: 826
I have below mysql query to run in laravel but i am not able to figure out how should i implement it.
Here is MYSQL query.
SELECT temp.*,count(temp.respondent_id) FROM (SELECT * FROM `responses` GROUP BY respondent_id) as temp GROUP BY DAY(`temp`.`created_at`)
I am getting expected result with it. Please help me out. Thanking you in advance.
Upvotes: 1
Views: 679
Reputation: 779
Try this,
$result = DB::select("SELECT temp.*,count(temp.respondent_id) FROM (SELECT * FROM `responses` GROUP BY respondent_id) as temp GROUP BY DAY(`temp`.`created_at`)");
Upvotes: 0
Reputation: 826
Hey I have got solutions.
As stachu given link "Solution 1" in comments.
& another way is as below
$data = \DB::select(\DB::raw('SELECT count(temp.respondent_id) as respondent, DATE(temp.created_at) as date FROM (SELECT * FROM `responses` GROUP BY respondent_id) as temp GROUP BY DAY(`temp`.`created_at`)'));
Hope this help.
Upvotes: 1