I have the tables products and history and I need to group by name: products = (id_product, name) history = (id_history, id_product, amount) I tried this SQL query but it isn’t grouped by name: …
Tag: join
Why is MySQL SUM query only returning one row?
I am trying to create a MySQL query to return the sum of all statement balances for each account in my DB. The query looks like this: SELECT SUM(balance), handle FROM statement_versions INNER JOIN …
Postgresql – Return a column resulting from join as single json column
I have a many to many relationship between users and roles table (A typical usecase). They are related together using a user_role table. I execute the below query: select u.id, u.first_name, u….
Calculate proportion (percent) [closed]
Could you help me to calculate proportion of Table user_id attendance Date 1 1 01.01.2018 2 Null 01.01.2018 3 1 02.01.2018 4 …
SQL SUM on multiple INNER JOIN
I am trying to get the sum of particular fields through multiple table using joins. I am getting the SUM wrong when I I try to get the values together. I have table State as I have another table Balance as I have one more table Loan as What I want as a result from my query is, When I
Using COUNT in INNER JOIN in SQLite (to count absent records)
In SQLite, I have a table named Items: | id | name | |—-|——-| | 1 | .. | | 2 | .. | | 3 | .. | | 4 | .. | | 5 | .. | | 6 | .. | Each item might have tags associated …
Getting all weeks data of a month using inner join
I have the following query: Above query explanation: I’m getting all weeks data PaidKM which driver gets in a whole month. The month for example starting date is 01-07-2018 and ending date is 31-07-2018 which covers whole month # 07. But when I change the month it gives me the same results all time. Abo…
Multiple joins in SQL statement
To clear things up, I have two tables, employees and jobs. In employees I have columns firstname, lastname, employees id. In jobs I have columns job_id, job_name, job_description, job_opener, …
How to join two tables with the same number of rows in SQLite?
I have almost the same problem as described in this question. I have two tables with the same number of rows, and I would like to join them together one by one. The tables are ordered, and I would …
How to find group which is having Status Active? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago. Improve this question I have a id which is having more than one Accountid in a table with status Active . I need t…