Skip to content
Advertisement

Count specific information in .db file

I wish to count the number of males and females in a specific city that the user chose. Here’s a gist of the .db file:

example_table

This is what I’ve coded so far based on the references I’ve read:

So far, that prints the overall number of males and females in the data. I’d like to ask how could I print the exact number of males and females in a city? Say I input “New York”, the result would be:

Advertisement

Answer

Add a WHERE clause restricting to a certain city, e.g.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement