Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how i can count  the number of message REPEATED

Posted on 2012-12-25
14
Medium Priority
?
336 Views
Last Modified: 2013-01-09
i have a table contain a msg field
and the message format is like :

Vote george
vote mbuzo
 format of the message is VOTE "NICKNAME"

I WANT TO COUNT THE NUMBER OF MSG FOR EACH NICKNAME ??
0
Comment
Question by:afifosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 4

Expert Comment

by:brendonfeeley
ID: 38720033
SELECT msg, COUNT(*) AS total FROM <table_name> GROUP BY msg ORDER BY total DESC;
0
 
LVL 1

Author Comment

by:afifosh
ID: 38720041
i want to count only message start with Voting followed by space !!
voting "nickname"
0
 
LVL 1

Author Comment

by:afifosh
ID: 38720042
and  the msg should be start with voting
0
Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

 
LVL 4

Expert Comment

by:brendonfeeley
ID: 38720088
SELECT msg, COUNT(*) AS total FROM <table_name> WHERE LOWER(msg) LIKE 'vote %' GROUP BY msg ORDER BY total DESC;
0
 
LVL 1

Author Comment

by:afifosh
ID: 38720114
it's dosen;t work with arabic  i have replace the word voting by arabic translated word and no result :S
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38720131
no points here, you have to use the correct "collate" keyword:
SELECT msg, COUNT(*) AS total 
FROM <table_name> 
WHERE LOWER(msg) LIKE 'vote %' COLLATE _your_collation_name_goes_here 
GROUP BY msg ORDER BY total DESC; 

Open in new window

0
 
LVL 1

Author Comment

by:afifosh
ID: 38720139
msg like '¿¿¿  %' dosen;t work
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38720147
well, I asked you to use COLLATE keyword ...
anyhow, with "arabic" data, I am not 100% sure how this works out, but it should be straightforward ...
0
 
LVL 1

Author Comment

by:afifosh
ID: 38720175
i have replaced voting in english with voting in arabic and it's dosen;t work :S
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38720187
can you show sample , so we could try to reproduce it?
I can only tell you that basically the query suggestion does work ...
0
 
LVL 1

Accepted Solution

by:
goldykhurmi earned 2000 total points
ID: 38720862
Try to write like this :

msg like N'¿¿¿  %'
0
 
LVL 1

Expert Comment

by:goldykhurmi
ID: 38720863
or
cast (msg as varchar(100)) like N'¿¿¿  %'

or
cast (msg as varchar(100)) like '¿¿¿  %'
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 38721062
Try this:
SELECT DISTINCT(REPLACE(message,'Vote ', '')) AS message, COUNT(*) AS votes
FROM _messages
GROUP BY message ORDER BY votes DESC

Open in new window

0
 
LVL 32

Expert Comment

by:awking00
ID: 38721360
select replace(message,'Voting ',null) as message, count(*) as cnt
from messages
group by replace(message,'Voting ',null)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question