Solved

how i can count  the number of message REPEATED

Posted on 2012-12-25
14
331 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

18 Experts available now in Live!

Get 1:1 Help Now