Abdu Abdul

Abdu Abdul

  • 1.3k
  • 409
  • 15.4k

Create PIVOT using mysql database and C#

Jan 12 2022 10:01 AM

Good day everyone. 

Please i have a small problem and easy for the genuis in this group. I want to PIVOT MYSQL data base on number of days in a month choosen

sample data

attendance

date
primary school 1-1-2020
primary school 1-1-2020
secondary school 1-1-2020
secondary school 1-1-2020
secondary school 2-1-2020
primary school 2-1-2020
primary school 3-1-2020

 SQL SERVER has a PIVOT statement which is not available on MYSQL.  my problem is i want to group the data base on the current month i chose, i dont want to use CASE statement because i cant i achieve what i want 

my expected outcome, let say i chose january as a month, i want the outcome to look like this

attendance 1-1-2020 2-1-2020 3-1-2020 4-1-2020 5-1-2020 6-1-2020 7-1-2020
primary school 2 1 1        
secondary school 2 1          

i want the outcome to give me complete month days irrespective of choosen month, i can get the sum of data but to get the complete month days is what i need help from. if any one has a better alternative can suggest to me please. 

thank you all.


Answers (4)