PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 2, 2022

[FIXED] SELECT MAX of COUNT

 February 02, 2022     mysql, phpmyadmin     No comments   

Issue

i made query to display the count of total number of positive and negative but i need to get or display only the maximum count of either positive or negative.this is my query

SELECT count(`sentiment`) as count,`sentiment` FROM `sno_social_listener` WHERE `keyword_id` = 104 group by `sentiment`

Solution

ORDER BY and LIMIT should be what you're looking for.

SELECT count(`sentiment`) as count,
       `sentiment` 
FROM `sno_social_listener` 
WHERE `keyword_id` = 104 
GROUP BY `sentiment` 
ORDER BY count DESC 
LIMIT 1


Answered By - pavel
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing