mercredi 3 août 2016

MySQL - Joining 3 Tables and Make one row as a column

I have tried to search for help on existing threads but I found myself at lost because of the answers.

Here's my scenario:

I have two tables: ACCOUNTS, NET_PROCEEDS

ACCOUNTS table has:

  1. Account_ID
  2. Account_Name
  3. Account_Description

NET_PROCEEDS table has:

  1. Net_Proceeds_ID
  2. Account_ID
  3. Fiscal_Year
  4. Amount

Now my basic sql can join two tables with this output:

Account_ID | Account_Name | Account_Description | Fiscal_Year | Amount

But I am trying to come out with this output:

Account_ID | Account_Name | Account_Description | 2016 | 2017 | 2018 | 2019

The fiscal_year will become a column with a value of amount.

Any thoughts? I will appreciate your help. P.S I can't share the code, due to confidentiality. Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire