1

I can't seem to get a basic SQL query to work in SQLite. It's just a single 8 column table in db-browser for sqlite. Some of the data-types aren't correct here, but it shouldn't impact end results

I'm getting no results returned, it should be 116 results.

Data represented in SQLite

enter image description here

Basic SQL statement

enter image description here

select
    `CountyName`,
    gender,
    sum(population)
from secondTable
where Year = 2014
group by `CountyName`, gender
order by `CountyName`, gender

2 Answers 2

2

It appears your "year" column is defined as type "TEXT".

If the rows where year is 2014 are actually "2014.0" (like all of the 2010 examples your picture shows), then the WHERE clause isn't going to match on them.

Sign up to request clarification or add additional context in comments.

Comments

1

Sqllite doesnt have a datetime type, so for comparison you have to so this:

select
    `CountyName`,
    gender,
    sum(population)
from secondTable
where Year = “2014”
group by `CountyName`, gender
order by `CountyName`, gender

If you have an actual date, there are functions like strftime

Comments

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.