Select values for a column only if there are no rows with that value that satisfy a condition

I have a table that stores logs of http fetches, let’s say we have two columns: fetch_url and success. A few example rows: success fetch_url TRUE A FALSE A FALSE B FALSE B FALSE …

SQL query filter down to only applicable rows

How would I select a query like this? I am a bit confused because this would return nothing since any of the rows do not fulfill any of the “where clauses”.. What I would like is the answer …

How to check if all instances of a DB row are the same and if so count + 1 in SQL?

I have the following SQLite DB table: app | vendor | active ——————— 123 | AGX | 1 123 | OTMA | 0 123 | PEI | 0 255 | IYU | 0 255 | MAG | 0 255 | MEI | 0 675 | IUU | …

Need to modify a variable data to use as a “LIKE” in a COUNT query

I’m trying to use a numeric variable on a LIKE statement, but I do not know how to change the data to a numeric value. Before we start, I apologize because I can’t copy the table structure as I’m …

Count the amount of likes a user received on each post sql

I have two tables. Likes table which contains it’s like_id (PK), vole_id, user_id, and created_at timestamp. And another table called voles that contain vole_id (PK), and user_id, as well as a bunch …

Pgsql find similar records in database

I have a table that has the layout of this sensor_id time value 1 2020-12-22 09:00:00 20.5 1 2020-12-22 10:00:00 21.5 1 2020-12-22 11:00:00 22.5 1 2020-12-22 12:00:00 23.5 2 2020-12-22 09:00:00 …

SQL – Count rows based on matching columns and value range

Please see below query using T-SQL with SSMS. There are three tables: B, G and L. B has a column Bname G has 2 columns Gname, Gross L has 2 columns Bname, Gname Gross column is an INT ranging …

Division of 2 values in mysql

Hello I’m a newbie in SQL. I have a table of workers and I want to calculate the avg num of female workers. I want to divide 2 tables that I create, but when I do the division the value of the new …

Postres SQL select with GROUP BY and COUNT

i have this SQL select SELECT t.debtor_account, COUNT(t.debtor_account) FROM transaction t GROUP BY t.debtor_account HAVING COUNT(t.debtor_account) > 2; which work, but i need select all from …

Can you use ORDER BY (column) LIMIT with a secondary column?

I want to find out the Top 10 rented movies in the sakila db. It must be sorted DESC after total_rentals and secondary after film title. My solution looks like this and works so far without the film …