skip to Main Content

enter image description herei have folowing table with emails an integer

I would have to add up all the integers and group them with the email to get a result EMAIL | COUNT. is something like that possible?

I try

SELECT 
      email,
      MAX( COUNT( IF( 500_K >= 1, 1, NULL)) 
        OR COUNT( IF( 1_Million >= 1, 1, NULL)) 
        OR COUNT( IF( 2_Million >= 1, 1, NULL)) ) 
   FROM 
      user__abzeichen


and

SELECT
      email, 
      COUNT( 500_K > 0
          OR 1_Million  > 0
          OR 2_Million  > 0
          OR 5_Million  > 0
          OR 10_Million  > 0
          OR Faehnrich  > 0
          OR Kapitaen  > 0
          OR Admiral > 0
          OR Thrall > 0
          OR Jarl > 0
          OR Koenig > 0
          OR Explosiv > 0
          OR Roter_Stern > 0
          OR Roter_Teufel > 0
          OR 1_Jahr > 0
          OR 2_Jahre > 0
          OR 5_Jahre > 0
          OR 10_Jahre > 0
          OR Unter_10_Prozent > 0
          OR Unter_5_Prozent > 0
          OR Unter_1_Prozent > 0
          OR Ehrenmitglied_1 > 0
          OR Ehrenmitglied_2 > 0
          OR Ehrenmitglied_3 > 0
          OR The_Big_Cut > 0
          OR Seelenbaum > 0 ) AS ANZ 
   FROM 
      user__abzeichen

2

Answers


  1. Chosen as BEST ANSWER

    select email, SUM('500_K'

    • '1_Million'
    • '2_Million'
    • '5_Million'
    • '10_Million'
    • 'Faehnrich' ) as count from user__abzeichen group by email

    that at al rows 518enter image description here


  2. Assuming the value is strictly int.

     select email, sum(`500_K` + `1_Million` + `2_Million` + `5_Million` + `10_Million` + `Faehnrich`....So on) as count
     from user__abzeichen group by email
    

    Simple as that no need to complicate.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search