Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help in "Pivot" query

Author  Topic 

Sarakumar
Posting Yak Master

108 Posts

Posted - 2009-05-07 : 23:07:34
Hai, i have got help from the forum members to build a pivot query.
now i can got some issue in the query. Again pls help me to sort it out.
declare @Customer table
(cid int,
item varchar(50),
in_use bit)
insert into @Customer values (1,'mobile',0)
insert into @Customer values (1,'TV',1)
insert into @Customer values(1,'Comp',1)
insert into @Customer values(1,'Laptop',0)
insert into @Customer values(2,'mobile',0)
insert into @Customer values(2,'TV',1)
insert into @Customer values(3,'mobile',1)
insert into @Customer values(3,'Laptop',1)

SELECT cid, [mobile],[TV], [Comp],[Laptop],in_use from
(select cid, item ,in_use from @Customer) st
pivot
(count(item) for item in([mobile],[TV], [Comp],[Laptop]))PT


As there are two diffrent values for in_use 0 or 1, im getting duplicate record..how can i eleiminate it

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-07 : 23:14:37
what is the in_use for ? are you only counting for in_use = 1 ?

what is the expected result ?

try removing the in_use col from your query if you don't need it


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Sarakumar
Posting Yak Master

108 Posts

Posted - 2009-05-07 : 23:41:56
Hai, Thanks. unnecessarly i got confused. there is no need to use the in_use..sorry for wasting ur time..
Go to Top of Page
   

- Advertisement -