Linked Questions

1 vote
0 answers
13 views

One parent 2 children sql join [duplicate]

I have 3 tables A,B,C. A is parent of B and C. I want to get the all A rows with sum of B and sum of c. Ex: table A: id 1 2 3 table B: id, parentid, data 1, 1, 12 2, 1, 23 3, 2, ...
user146324's user avatar
15 votes
1 answer
38k views

SUM over distinct rows with multiple joins

Schema: CREATE TABLE "items" ( "id" SERIAL NOT NULL PRIMARY KEY, "country" VARCHAR(2) NOT NULL, "created" TIMESTAMP WITH TIME ZONE NOT ...
Stranger6667's user avatar
4 votes
3 answers
4k views

LEFT JOIN Producing Inflated COUNT() numbers

I have 3 tables that I am using a Right Join on. The data is setup like below - and my issue with it is that numbers being returned are inaccurate, such that when I execute the query I get this ...
BellHopByDayAmetuerCoderByNigh's user avatar
1 vote
1 answer
12k views

How to create the multiple sum query with joins

Please consider following database: Table `invoices`: -- invoice_id Table `amounts`: -- amount_id invoice_id type_id amount I am trying to get the sum for each type from table like this: SELECT ...
guest's user avatar
  • 35
3 votes
3 answers
2k views

Sum values from child tables and ignore equal rows

I have two child tables with a value that must be summed separately and at the end the totals must be subtracted. The problem is that Child Table A and Child Table B can have 0 or more rows associated ...
juliano.net's user avatar
1 vote
2 answers
4k views

How get the sum of two tables value using inner join

There are there tables the below image. My question is retrieve from each customers and get the sum of Invoice total due, Invoice Total balance in invoice table and return cheque total due and return ...
M.I.M.F's user avatar
  • 329
2 votes
1 answer
3k views

Join multiple table with unique data

I have 4 Tables. i.e. crm_entry(id, prefix, firstname, lastname), crm_phone(id, crm_id, extension,value), sale_order(id, crm_id) and purchase_order(id, crm_id) I want a table like this.. | id | ...
mauliksompura's user avatar
2 votes
2 answers
1k views

MYSQL joining 3 tables with left join

I have these tables: pupils: (id_pupil, name, surname, email, user, pass, level, class) incidents: (id_incidents, date, time, type_incident, comments, id_pupil, id_user, subject, id_trimester) ...
Alonso González Nestal's user avatar
0 votes
1 answer
1k views

Calculation is not correct during in the left join table

At the moment My head is bang on the wall as I have used few of dba.stackexchanged.com example but none of them is working. AS I'm trying to get SKU that it sold on each Country, as I have 5 country ...
Steven Smith's user avatar
0 votes
1 answer
795 views

Getting Skewed Results from LEFT OUTER JOIN with 3 TABLES

I have 3 tables, users (user info), mghours (volunteer time), mgtraining (training time). I want a result that lists some user columns, sum of volunteer hours and sum of two types of training: uid ...
RJ Jacob's user avatar
1 vote
1 answer
75 views

join from different tables gives same result, but it shouldn't

This is the code I'm using and I'm having a problem with it. SELECT `disenos`.*, `votos`.`valoracion`, `usuario_contacto`.`nombres`, `usuario_contacto`.`apellidos`, `users`.`username`, `users`.`...
Alejandro's user avatar
  • 147