S
S
szjyakgf2022-03-22 12:22:52
SQLite
szjyakgf, 2022-03-22 12:22:52

How to find out the number of 1s in a sqlite column?

I work with sqlite3 in Python
There is a users table, how to find out the number of 1 from a certain column (with numbers 1,2,3)?
For example, in a column five 1, three 2 and ten 3. How can I display the number 5 (amount 1)

xxx = cur.execute("SELECT COUNT(*) FROM users GROUP BY '%s' HAVING '%s' == 1" % (mmnl, mmnl,)).fetchone()
print(xxx)

But I get not 5, but None
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2022-03-22
@szjyakgf

SELECT COUNT(*) FROM users WHERE column_name == 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question