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
Dynamically show all of gridview and expand page
How do I change the Read-only staus of NTFS folders under XP?
Does anyone know if there is VNC fix for Windows 7
Change div position when checkbox is checked/unchecked
Filling a dataset without locking the database?
Exchange 2010 stoirage design Part II
Where can I buy an Apple LaserWriter II?
Users can't reconnect to RemoteApp Session
What datatype should a rul string be in to pass from code behind into URL via response.redirect
no display while booting Linux live cds for HP EliteBook 8440p