Member_2_6478753
asked on
how i can count the number of message REPEATED
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 ??
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 ??
SELECT msg, COUNT(*) AS total FROM <table_name> GROUP BY msg ORDER BY total DESC;
ASKER
i want to count only message start with Voting followed by space !!
voting "nickname"
voting "nickname"
ASKER
and the msg should be start with voting
SELECT msg, COUNT(*) AS total FROM <table_name> WHERE LOWER(msg) LIKE 'vote %' GROUP BY msg ORDER BY total DESC;
ASKER
it's dosen;t work with arabic i have replace the word voting by arabic translated word and no result :S
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;
ASKER
msg like '¿¿¿ %' dosen;t work
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 ...
anyhow, with "arabic" data, I am not 100% sure how this works out, but it should be straightforward ...
ASKER
i have replaced voting in english with voting in arabic and it's dosen;t work :S
can you show sample , so we could try to reproduce it?
I can only tell you that basically the query suggestion does work ...
I can only tell you that basically the query suggestion does work ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or
cast (msg as varchar(100)) like N'¿¿¿ %'
or
cast (msg as varchar(100)) like '¿¿¿ %'
cast (msg as varchar(100)) like N'¿¿¿ %'
or
cast (msg as varchar(100)) like '¿¿¿ %'
Try this:
SELECT DISTINCT(REPLACE(message,'Vote ', '')) AS message, COUNT(*) AS votes
FROM _messages
GROUP BY message ORDER BY votes DESC
select replace(message,'Voting ',null) as message, count(*) as cnt
from messages
group by replace(message,'Voting ',null)
from messages
group by replace(message,'Voting ',null)