title: Get RMSE score while fetching data from the Table directly.Write a query for that
body: <p>I have a table in the Database which has many features each feature is having its own actual and predicted value in its and we have two more column which is Id_partner and Id_accounts.My main goal is to get the RMSE score for each feature for each accounts in each partners, I have done that with the for loop but it is taking hell lot of time to complete in PySpark is there an efficient way of doing that directly with the help of query while reading the data only so I get the RMSE score for each accounts in each partner.
  My Table is something like this</p>
  
  <pre><code>Actual_Feature_1 = Act_F_1  
  Predicted_Feature_1 = Pred_F_1  
  Actual_Feature_1 = Act_F_2  
  Predicted_Feature_1 = Pred_F_2  
  </code></pre>
  
  <p>Table 1:  </p>
  
  <pre><code>ID_PARTNER | ID_ACCOUNT | Act_F_1 | Pred_F_1 | Act_F_2 | Pred_F_2 |  
       4     |    24      |   10    |    12    |   22    |    20    |  
       4     |    24      |   11    |    13    |   23    |    21    |  
       4     |    24      |   11    |    12    |   24    |    23    |  
       4     |    25      |   13    |    15    |   22    |    20    |  
       4     |    25      |   15    |    12    |   21    |    20    |  
       4     |    25      |   15    |    14    |   21    |    21    |  
       4     |    27      |   13    |    12    |   35    |    32    |  
       4     |    27      |   12    |    16    |   34    |    31    |  
       4     |    27      |   17    |    14    |   36    |    34    |  
       5     |    301     |   19    |    17    |   56    |    54    |  
       5     |    301     |   21    |    20    |   58    |    54    |  
       5     |    301     |   22    |    19    |   59    |    57    |  
       5     |    301     |   24    |    22    |   46    |    50    |  
       5     |    301     |   25    |    22    |   49    |    54    |  
       5     |    350     |   12    |    10    |   67    |    66    |  
       5     |    350     |   12    |    11    |   65    |    64    |  
       5     |    350     |   14    |    13    |   68    |    67    |  
       5     |    350     |   15    |    12    |   61    |    61    |  
       5     |    350     |   12    |    10    |   63    |    60    |  
       7     |    420     |   51    |    49    |   30    |    29    |  
       7     |    420     |   51    |    48    |   32    |    30    |  
       7     |    410     |   49    |    45    |   81    |    79    |  
       7     |    410     |   48    |    44    |   83    |    80    |  
       7     |    410     |   45    |    43    |   84    |    81    |
  </code></pre>
  
  <p>I need the RMSE score for each account in each partners in this format</p>
  
  <p>Resulted Table : </p>
  
  <pre><code>ID_PARTNER | ID_ACCOUNT |  FEATURE_1  |  FEATURE_2  |  
      4      |     24     | rmse_score  | rmse_score  |  
      4      |     25     | rmse_score  | rmse_score  |  
      4      |     27     | rmse_score  | rmse_score  |  
      5      |     301    | rmse_score  | rmse_score  |  
      5      |     350    | rmse_score  | rmse_score  |  
      7      |     420    | rmse_score  | rmse_score  |  
      7      |     410    | rmse_score  | rmse_score  |  
  </code></pre>
  
  <p>Note : For this we need to do consideration of both id_account and id_partner by seeing the above table i.e actual table we see that id_accounts can be just used for getting rmse but different id_partner can have the same accounts as other partner is having.
  I need an SQL query that provides the resulted table directly while reading the table from the database.</p>