TSQL Calculation

  • I have a staging table that I am using to do my calculation into the final table.

    In my staging table I have all the necessary columns to do the calculations. But I am having trouble do so. Can anyone help me solve this problem.

    Here is my query...again, all of my calculation will be done from columns of the summary table.

    SELECT

    lease_new_days_count

    ,lease_new_vacancy_days

    ,lease_original_vacancy_days

    ,lease_new_amount

    ,lease_original_amount

    ,lease_new_move_cost

    ,thc_new_lease

    ,thc_original_lease

    , (((thc_new_lease - thc_original_lease / 30.5) * lease_new_vacancy_days)

    + (((lease_new_amount - lease_original_amount ) / 30.5)

    * (lease_new_days_count - lease_new_vacancy_days))

    ,((thc_new_lease / 30.5 ) * (lease_new_vacancy_days )) total_vacancy_amount_new

    FROM dbo.summary

    --the error that I get

    Msg 102, Level 15, State 1, Line 16

    Incorrect syntax near ','.

  • Your parenthesis don't match, You have an extra open one, and you need to either remove it or determine where you're missing the closing one.

  • Try

    ((lease_new_amount - lease_original_amount ) / 30.5)

    you have 7 opening and 6 closings in it.

    SQL DBA.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply