0

enter image description here

I am writing a SQL query and encounter a situation that I want to obtain a table instead with 156 (stands for customer number of female) and 180 (stands for customer number of male) in the same column, but with them in the same row using 'select from where' statement. (not building a new table) I would like the result table to be France, Bachelors, 156, 180. How should I do it simply? Thank you!

P.S. if I also don't want to use pivot_table statement.(I can also add an extra column with 'F' or 'M' if needed)

tsen0406
  • 119
  • 3
  • 4
  • 15
  • 1
    FYI, this is called *pivoting* your table. It's a notorious pain in the neck in MySQL. Knowing what it's called may help you search for a solution. – O. Jones Nov 27 '17 at 19:51
  • Yes, @O.Jones, but only if they are seeking to aggregate based on customer number. Predicting how this might be useful, you're probably right. But the tsen could get what they are asking for from 2 columns using coalesce. – n8. Nov 27 '17 at 19:56

0 Answers0