Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Individual count of text from a column
Guruprakash C
Oct 5 2017 2:53 PM
224
Reply
Hai,
I need to display count of each text occurrence on all rows from a particular column.
See result below:
Here I have a set of Tags, I need to display count each tag as column in the name 'Total'
What I have done is:
DECLARE
@tags
VARCHAR
(8000)
DECLARE
@tot
INT
select
@tags =
coalesce
(@tags +
','
,
' '
) + Labels
from
addNew
select
@tot =
count
(@tags)
select
a.Labels
as
Tags,@tot
as
Total
from
addNew a
inner
join
addNew n
on
a.Labels = n.Labels
group
by
a.Labels
the result must be:
Please suggest your queries to get my desired result.
Thank in Advance.
Attachment:
SQLQuery.rar
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
A severe error occurred on the current command
Please help me to optimize below stored procedure