Microsoft
Software
Hardware
Network
Question : COUNT_variable Error
I to have tblModellTmp with HP_4 values which represent the Sector for each company. I would like now to count how many companies are in each Sector and then in a second step, save this value for each company in HP_5 so I know for each how many competitors around. But I get already an error in my first line saying the subquery has gave back more then one value
SET @HP_4_Count = (SELECT COUNT(HP_4)FROM tblModellTmp WHERE (T = 1)GROUP BY HP_4)
UPDATE tblModellTmp
SET HP_5 = @HP_4_Count
the simble query
SELECT COUNT(HP_4) AS Expr1, HP_4
FROM tblModellTmp
WHERE (T = 1)
GROUP BY HP_4
gives back
Expr1 HP_4
78 Elektrogeräte & Bauteile
72 Freizeit, Unterhaltung, Hobbies
42 Möbel, Hausrat, Haushaltgeräte
...
Any idea how to solve?
thx
Kongta
Answer : COUNT_variable Error
sorry
UPDATE u
SET HP_5 = x.expr1
from tblmodelltmp as U
inner join (
SELECT COUNT(HP_4) AS Expr1, HP_4
FROM tblModellTmp
WHERE (T = 1)
GROUP BY HP_4
) as x
on u.hp_4=x.hp_4
where u.hp_5 <> x.expr1
Random Solutions
Instanciate a "Type"
Thinkpad z60m wireless adapter shows with yellow ?
OnSelectedIndexChanged not firing when user tabs
What is the impact of recreating an OU certifier on current users?
.NET Citrix SDK
Why am I locked out of my files?
Reading various textfiles according to Encoding
Devcon rescan/Device Manger scan for hardware changes or new hardware
Windows 2008 R2 Server local security policy is locked?
What is the equivalent of html anchor control's name attribute in asp.net Hyperlink control