left-join

How to do LEFT JOIN with double condition in Oracle syntax?

前提是你 提交于 2020-07-20 03:57:45
问题 I have 2 tables. 1) car table: 2) param table: I need to fetch duplicate cars have owner params match and do NOT differ in insurance (that's it must be either the same or is absent for both ). I'm successfully executing my query with LEFT JOIN in ANSI-syntax: SELECT owner.name, owner.value, COALESCE (insur.name, 'insurance'), insur.value, count(*) FROM car INNER JOIN param owner ON car.id = owner.car_id LEFT JOIN param insur ON car.id = insur.car_id AND insur.name = 'insur' WHERE owner.name =

mySQL sum of two values in 2 different tables

爷,独闯天下 提交于 2020-06-27 16:43:28
问题 I have 2 identical tables with identical columns in each one - "quantity" and "reference". The values in these columns are set out as follows: table_1 reference quantity TS00001 235 TS00002 400 TS00003 850 ... table_2 reference quantity TS00001 670 TS00002 210 TS00003 150 ... I need to join the tables and output the sum of the quantity field for each matched reference ID e.g: reference total_quantity TS00001 905 TS00002 610 TS00003 1000 ... I've been trying LEFT JOIN and other methods but I'm

mySQL sum of two values in 2 different tables

蓝咒 提交于 2020-06-27 16:43:18
问题 I have 2 identical tables with identical columns in each one - "quantity" and "reference". The values in these columns are set out as follows: table_1 reference quantity TS00001 235 TS00002 400 TS00003 850 ... table_2 reference quantity TS00001 670 TS00002 210 TS00003 150 ... I need to join the tables and output the sum of the quantity field for each matched reference ID e.g: reference total_quantity TS00001 905 TS00002 610 TS00003 1000 ... I've been trying LEFT JOIN and other methods but I'm