locked
Error trying to use derived table within Update. RRS feed

  • Question

  • User-581139276 posted

    Hi,

    this is my query,

    UPDATE Municipalities SET AvgResTownHousePriceChange30 = (CONVERT(float, 0 ) / CONVERT(float, (Table1.AvgResTownhouse30))) * 100 from(SELECT AvgResTownhouse AS AvgResTownhouse30 FROM StatsMunicipalities AS StatsMunicipalities_1 WHERE(DateCreated = 'July 07, 2016') AND(Municipality = 'Adjala-Tosorontio') AND(Community = 'Everett')) as Table1 , TotalResListings = 11 where RecordID = 1

    I've getting the following error:

    incorrect syntax near '='

    I can't seem to get the derived table to work within query above, any suggestions would be greatly appreciated.  thank you..

    Saturday, August 6, 2016 6:56 PM

Answers

  • User-1716253493 posted

    Try modify like this

    UPDATE Municipalities SET AvgResTownHousePriceChange30 = (SELECT (CONVERT(float, 0 ) / CONVERT(float, (Table1.AvgResTownhouse30))) * 100 FROM ...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 7, 2016 1:49 AM

All replies

  • User-1716253493 posted

    Try modify like this

    UPDATE Municipalities SET AvgResTownHousePriceChange30 = (SELECT (CONVERT(float, 0 ) / CONVERT(float, (Table1.AvgResTownhouse30))) * 100 FROM ...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 7, 2016 1:49 AM
  • User-581139276 posted

    Hi,

    thanks, I've got it half working now, I'm getting a divide by zero in some cases and now am having problems using a iif( in combination with my query, I will post that a another question..

    thanks, 

    Sunday, August 7, 2016 12:31 PM