Skip to main content

Forgive me for the lack of updates lately. It’s been a busy late Spring.

All is really good here in the Shawver household – in fact it’s better than it has been in a long time. We are healthy and happy, and peaceful.

One of the things I’ve been wanting to do is to write more – but I’ve also been hesitant. If you really know me, I have a lot of opinions and thoughts. However, I want to make sure I am sharing things that are valuable. That said,  I’ve been really wanting to work some of my technical work into my blog. With my various hats, I’m getting a lot of cool technical knowledge.

So today, and going forward, I’m going to add a technical tag to my blog, with specific technical learnings. I also am going to throw out some random fiction and other things. Keep on the lookout. Make sure to subscribe. Keep checking back. In the meantime, see if you can solve this. Feel free to comment your solutions below

SQL Brain Teaser 1

There are two tables

Family

ID Family_Name
1 Smith
2 Thiel
3 Davis

Kids

ID Child_Name Family_ID Gender Age
1 Jamie 1 M 7
2 Gina 1 F 12
3 Chase 1 M 11
4 Fred 3 M 4
5 Bob 3 M 7
6 Dave 2 F 1

 

We are trying to count the number of families with children. The follow statement is giving 4 familes, not 3. What is causing the error?

 

SELECT count(f.id) FROM

Family f

INNER JOIN

(SELECT distinct Family_ID, Gender FROM Kids) k

ON f.id = k.Family_ID;

Leave a Reply