gufran gufran - 1 year ago 66
SQL Question

how to update table with multiplication function?

when i tried update my table with this query

update sekolah set [rata-rata] =
(select ([total siswa]*12) from sekolah
where [class]='7IPA' and month([Date]) = 08)
where [class]='7IPA' and month([Date]) = 08

a message is :

Subquery returned more than 1 value. This is not permitted when the
subquery follows =, !=, <, <= , >, >= or when the subquery is used as
an expression.

my table is sekolah

my field is :

total siswa

Answer Source

If both are same table then it will be helpful:

UPDATE s SET s.rata-rata = (s.[total siswa]*12)
FROM sekolah s
where s.class='7IPA' and month(s.Date) = 08 


UPDATE sekolah SET 
rata-rata = ([total siswa]*12) WHERE class='7IPA' and month(Date) = 08
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download