I need to make a query (not another table, I'm trying to avoid that please) joining 3 tables. I have one table that specifies ownership schemes, like this:
+--------------------------------------------+
|id_scheme | scheme_name | registration_date |
+--------------------------------------------+
and another table which contains medical equipment, these have one ownership scheme and a supplier id, and finally another table which contains the suppliers, so, I need a query that can tell me for every supplier, how many equipments i have, and how many of these equipments I have in each ownership scheme category. I don't know how to write a query that use the rows of a table (all my ownership schemes) as a query result columns. So, the query can return something like this:
+-----------------------------------+
|supplier|equipments|acquired|leased|
+-----------------------------------+
|Philips | 50 | 13 | 30 |
+-----------------------------------+
or like this:
+----------------------------------------------+
|supplier|equipments|acquired|leased|commodatum|
+----------------------------------------------+
|Philips | 50 | 13 | 30 | 7 |
+-----------------------------------+----------+
and so on. Please, your help will be very appreciated.
EDIT I put an example of what i want in the image, the equipment and suppliers tables of course have more columns, but i thinks thats all i need to build the query