Solved

how i can count  the number of message REPEATED

Posted on 2012-12-25
14
329 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
  • 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
 
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 142

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 142

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 142

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 500 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 31

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now