title: PostgreSQL crosstab query with multiple columns and week day
body: <p>I'm trying to create a pivot by grouping several columns: user id, name, week number and the name of the day.
  The current request does not give the desired result.
  I need help.</p>
  
  <p><strong><em>Here is my table:</em></strong></p>
  
  <pre><code>user_id name    week_number day_name    price
  2       Luc     8           Sunday      10
  2       Luc     8           Monday      15
  2       Luc     8           Tuesday     8
  2       Luc     8           Wednesday   2
  2       Luc     8           Thursday    9
  2       Luc     8           Friday      9
  2       Luc     8           Saturday    11
  2       Luc     9           Saturday    1
  2       Luc     9           Friday      13
  3       Mathieu 8           Sunday      22
  3       Mathieu 8           Monday      13
  3       Mathieu 8           Tuesday     9
  3       Mathieu 8           Wednesday   3
  </code></pre>
  
  <p><strong><em>Here is my current request:</em></strong></p>
  
  <pre><code>SELECT *
  FROM   crosstab(
  'SELECT user_id, name, week_number,day_name,price
  FROM   table_1
  ORDER  BY 1,2,3,4' 
  ) AS ct (
  "user_id" integer,
  "day_name" text,
  "Sunday" integer,   
  "Monday" integer,   
  "Tuesday" integer,  
  "Wednesday" integer,    
  "Thursday" integer, 
  "Friday" integer,   
  "Saturday" integer
  );
  </code></pre>
  
  <p><strong><em>And here are the results I want to get.</em></strong></p>
  
  <p><a href="https://i.stack.imgur.com/zSUn5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zSUn5.png" alt="enter image description here"></a></p>