Elizabeth G
asked on
SQL Query for pivot and calculation.
Am trying to write a sql query to get the data in a particular format. Please see my actual data below and the result am trying to get.
Sport Team No of Females No of males
Baseball Varsity 20 0
Baseball Varsity 20
Football Varsity 15
Above is the format of the table and data in the actual database.
Now i want to get the data in this below format.
Female Only Male only Total
Sports 1 2 2
Teams 1 2 3
Participants 20 35 55
Please help me with the sql query , I tried using pivot and count of the columns but i couldn't achieve the way i wanted. Thanks for your help!.
Sport Team No of Females No of males
Baseball Varsity 20 0
Baseball Varsity 20
Football Varsity 15
Above is the format of the table and data in the actual database.
Now i want to get the data in this below format.
Female Only Male only Total
Sports 1 2 2
Teams 1 2 3
Participants 20 35 55
Please help me with the sql query , I tried using pivot and count of the columns but i couldn't achieve the way i wanted. Thanks for your help!.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome! (Btw, this q of yours put me over 10M point mark, Thanks!)
ASKER