Get the source of the results in a COUNT

0

I have two tables: swipe and eclipse_hastag :

Here is the table eclipse_hastag :

Here is the swipe table:

I want to know what are the hashtag_id that have more than state=3,6,9 I get what I want with a COUNT but I do not know how to write next to the results the hastag_id :

SELECT COUNT (swipe.state) FROM swipe
  INNER JOIN eclipse_hashtag ON eclipse_hashtag.eclipse_id = swipe.eclipse_id
  WHERE swipe.state= 3 OR swipe.state = 6 or swipe.state=9
    GROUP BY eclipse_hashtag.hashtag_id
      ORDER BY COUNT(swipe.state) DESC;
    
asked by ThePassenger 16.05.2017 в 17:35
source

1 answer

5

In that case with putting it in the select should appear

SELECT COUNT (swipe.state), eclipse_hashtag.hashtag_id FROM swipe
      INNER JOIN eclipse_hashtag ON eclipse_hashtag.eclipse_id = swipe.eclipse_id
      WHERE swipe.state= 3 OR swipe.state = 6 or swipe.state=9
        GROUP BY eclipse_hashtag.hashtag_id
          ORDER BY COUNT(swipe.state) DESC;
    
answered by 16.05.2017 / 17:49
source