1

I am trying to count the rows by created_at like

Created_at                        COUNT(*)
----------------------------------- ----------
2017-08-13                                    5
2017-08-12                                    6
2017-08-11                                    7
2017-07-10                                    8
2017-07-19                                    1

So I can show the client like in 2017-07-10, there are 8 people signed up. In 2017-08-13, there are 5 people signed up or something like that.

Here is what I tried,

$count=DB::table('jobseekers')->select('created_at')->groupBy('created_at')->count();
    // return $count;
    dd($count);

but this is just showing only the number.

1 Answer 1

4

You could try something like this:

$count = DB::table('jobseekers')
             ->select('created_at', DB::raw('count(*) as peoples'))
             ->groupBy('created_at')
             ->get();
Sign up to request clarification or add additional context in comments.

2 Comments

Hi how to union the other tables using this concept? Can you show me the tips? thanks dude
@ThanHtutOo I don't see any other tables? Could you please make another question and state there explicitly which are the tables you want to perform a union, with a sample input and a sample output? This way it would be helpful for others also. Thanks !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.