how to show this table value from below output can u send coding.
id field
1 x
2 x
3 x
4 y
5 y
6 z
------------------
output
3x
2y
1z
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jul 14, 2012, 4:18 AM EDT
Here is my sample demo
create table test(
id int,
valued varchar(2))
insert into test values(1,'x')
insert into test values(2,'x')
insert into test values(3,'x')
insert into test values(4,'y')
select Cast(COUNT(1) as varchar)+ valued from test group by valued:
output-
3x,
1y
Vilas GiteRank #951 · 2.1K reputationPosted Jul 14, 2012, 6:13 AM EDT
Follow Santosh Kumar query... perfect
for more details about cast-convert in sql.
http://msdn.microsoft.com/en-us/library/ms187928.aspx
Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Jul 14, 2012, 7:50 AM EDT
create database demo
use demo
create table tabs(id int,chr char(1))
insert into tabs values('1','x')
insert into tabs values('2','x')
insert into tabs values('3','x')
insert into tabs values('4','y')
insert into tabs values('5','y')
insert into tabs values('6','z')
select * from tabs
select (cast(count(chr) as char)+chr) as result from tabs group by chr
output
result
------------
3x
2y
1z
manuel joseph153 reputationPosted Jul 17, 2012, 12:28 AM EDT