365 Days of Daily Coding: Day 30
Wow! It’s day 30 already. I am quite proud of myself for how far I have come. There were hiccups where in I stopped posting for 10 plus days after I took a 1 week hiatus for being sick and stressed.
I am feeling quite unwell today but I still made myself post this. It makes me realise that sometimes I just use being sick or stress as an excuse for not completing a task. That’s when you do not enjoy the process or are clear of the why. I love solving the SQL challenges at the same time doing these blog posts. I can’t wait to complete my 365 SQL posts and move onto python which is also one of the programming language I learnt while completing my Udacity Data Analytics Nanodegree and want to further work on it.
Today’s challenge: Give a table, I had to find out the count of the last_names (‘DAVIS’, ‘BRODY’, ‘ALLEN’, ‘BERRY’) in the table.
Table: actor
| col_name | col_type |
|---|---|
| actor_id | integer |
| first_name | text |
| last_name | text |
Expected output:
| last_name | count |
|---|---|
| Allen | 3 |
| Davis | 3 |
My solution:
SELECT last_name, count(*) AS count
FROM actor
WHERE last_name IN ('DAVIS', 'BRODY', 'ALLEN', 'BERRY')
GROUP BY last_name;

Leave a comment