1

Topic: To generate the report

Hello. Please, help to generate the report. There are three tables Shop , fields at all identical.
Magazin1 - - - - - - - - - - - - - - - Magazin2 - - - - - - - - - - - - - - - - - Magazin3
------------------------------------------------------------------------------------------------------
Title | the Description - - - the Title | the Description - - - the Title | the Description
------------------------------------------------------------------------------------------------------
Potato | the Potato - - - the Potato | the Potato? - - - a notebook |
Potato |???
Vodka | Vodka
On an output such table necessary approximately:
The Title | Magazin1 | Magazin2 | Magazin3 | All
Potato - - - 2 - - - - - - - - - 1 - - - - - - - - 0 - - - - - - - - 3
Notebook - - - - 0 - - - - - - - - - 0 - - - - - - - - 1 - - - - - - - - 1
Vodka - - - - - 1 - - - - - - - - - 0 - - - - - - - - 0 - - - - - - - - 1

2

Re: To generate the report

Three subqueries, count of amounts under each table. The fourth subquery - UNION, collecting titles from all tables. LEFT JOIN first three to the fourth, and COALESCE for changeover NULL by zero.