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` …
Tag: count
SQL count products
I have table: name product john beer john milk john tea john beer emily milk emily milk emily tea john beer i need select from this table, when output will be: name …
How to join 3 tables in SQL
I have 3 tables: Table 1 id | email —+———- 1 | a@a.com 2 | b@a.com 3 | c@a.com 4 | d@a.com Table 2 order_id | email ———+————– 1 | a@a.com 2 …
Finding daily registered users
I have a table which includes the information of player_id, first_timestamp, last_timestamp, and date, etc. So I have initially 10 payers on 2020-07-08, and then 18 players on 2020-07-09, some of the players from previous day might appear on 2020-07-09 again. And I’m trying to find the new players registered on 2020-07-09 that did not appear on 2020-07-08, but I
How to exclude weekends and holidays dates and find an expected date in MySQL?
I am working on a task where I have 2 tables. i.e, tickets and holidays. Now I also have the number of days to complete the tickets. Now I need to find the expected date by excluding holidays(specified in the holidays table) and weekends. Now I can able to find a date using ticket created date and days to complete
How to get a continuous group of id
I’d like to increment an id by group, for each variation of an attribute with only 2 values. like this : result wanted I tried dense_rank() with window function but i only gives me 1 or 2 in grp column Answer You can use window functions to solve this gaps and islands problem. Her is an approch using lag() and
Finding the most active video maker within multiple tables(SQLite)
How can I find the initials of the most active video maker, the one that made the most videos considering the following tables using only one query? CREATE TABLE IF NOT EXISTS Videos ( title TEXT …
SQL count number of records in one set of data compared to another and present as a percentage
I would like to count the number of unique records not matching on 2 key variables from Data B compared to Data A and present the result as a percentage of the total unique records in Data B. Data A: …
Generating counts of open tickets over time, given opened and closed dates
I have a set of data for some tickets, with datetime of when they were opened and closed (or NULL if they are still open). We would like to generate a table of data showing the total count of tickets that were open through time, grouped by date. Something like the following: Note that I am not sure about how
Counting Business Days PostgresSQL
I am attempting to do something like this: SELECT t.id, t.startdate, t.enddate, FOO FROM table Where “Foo” is some sql mumbo-jumbo to calculate the business days between startdate and …