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
Exchange and system state backup software for Windows 2008
data grid view format the boundfield to show as currency or as a date in c#
Need to wipe personal data from a Windows XP machine
Script for reloading FreeRadius config files on NAS MySQL update
Preventing of copying certain file types via Group Policy
servlet download file with javascript enabled
text-decoration: none not working on firefox?
Replaced router from Asus to Dlink now cannot remotely connect to SQL server
Printing MS Access 2007 / 2010 report to PDF in a specific folder on local hdd
rbac and su on aix