Add values of two different tables according to the selected id

1

I have the table "inventory_ticket" this has quantityTicket, and the table "inventory_list", what I want to do is a query that allows me to add the amounts of the two tables but according to the id that is set as fk_inventory in "inventoy_Ticket"

I tried this:

select (
    (select sum(quantityTicket) from quantityTicket) +
    (select sum(quantity) from inventory_list) 
where fk_Inventory = 108

But I get the following error saying that my syntax is incorrect:

    
asked by Pato 01.11.2018 в 18:20
source

1 answer

0

you can do it like this:

select sum( (select 
sum(quantity) from inventory_list ) + (select sum(quantityTicket) from quantityTicket where fk_Inventory = 108 )) as "sum"
  • in your query you are missing a parenthesis
  • select but not add
  • the fk_Inventory = 108 you put it global and both tables do not have it!
  • answered by 01.11.2018 / 19:12
    source