title: An aggregate may not appear in the set list of an UPDATE statement Error with randomized set value
body: <p>I am trying to execute this SQL script via Management Studio, but I get this error:
  An aggregate may not appear in the set list of an UPDATE statement. I've tried some other statements but I couldn't find any solution for my randomized set value. Many thanks for helps!</p>
  
  <pre><code>UPDATE G SET G.SAAT = DATEADD(d, ROUND(DATEDIFF(d, DATEADD(hh,2, MIN(G2.SAAT)),
  DATEADD(dd,6, T.CIKIS_TARIHI)) * RAND(CHECKSUM(NEWID())), 0),DATEADD(second,CHECKSUM(NEWID())%48000, G2.SAAT))
  FROM GONDERI_HAREKET G
  INNER JOIN GONDERI_HAREKET G2 ON G2.TAKIP_NO = G.TAKIP_NO
  INNER JOIN TESLIM_FORMU T ON G.TAKIP_NO = T.TAKIP_NO
  WHERE G.ISLEM_KODU = 15
  AND G2.ISLEM_KODU = 10
  AND G.SAAT &lt; G2.SAAT
  AND YEAR(T.CIKIS_TARIHI) = 2014
  AND (MONTH(T.CIKIS_TARIHI) = 1 OR MONTH(T.CIKIS_TARIHI) = 2)
  AND T.MUSTERI_KODU = 2483
  </code></pre>