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 | …

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 …

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 …

SQL – Find Record count for multiple tables at a time in snowflake

I want to see counts have Tables at 1 time, instead of Running each. For EX: select COUNT(*) from “Fact_MASTER “; select COUNT(*) from “Dim_MASTER “; select COUNT(*) from “…

How can I calculate a percentage from values obtained by 2 different queries in SSMS?

First query: select COUNT(EUpdate) from EmpUpdates where EProj = ‘abc’ and EID = ‘101’; Second query: select COUNT(EProj) from EmpUpdates where EID = ‘101’; percentage = (first query / second …

SQL – select where for specific id, all distinct values for other column exist

I am having a bit of a hard time explaining the logic I want to achieve in the title. Anyway, I have a database containing two tables (rent and car). The car table contains data about cars (license …

PostgreSQL, summing multiple date columns over multiple rows

Let’s assume the following table: CREATE TABLE assumption ( datetime_1 TIMESTAMP, datetime_2 TIMESTAMP, datetime_3 TIMESTAMP); Now I want to know the total amount of times a month is set in any row …

Date distinct count over week

Im trying to get a distinct count of user ids logs per day with every week as a partition for the distinct identification. e.g. if one user logs on Friday/Saturday of week 1, and on Monday/Friday of …

Postgres: how to check for records in time buckets for multiple values

I have a POSTGRES table with roughly the following shape: sensor_id | recorded_at ———-+——————– A | 2020-01-01 00:00:00 A | 2020-01-01 00:03:00 B | …

MySQL COUNT and IFNULL

I have tables like this: SQLFIDDLE I’m trying to count how many products are in each category SELECT `category_id`, `category_name`, IFNULL(count(*),0) cat_stat FROM `product_to_categories` …