sql - Update query: subquery returned more than 1 value -


i'm trying update table (yahoostockdata) information extracted table (incomestatement), depending on date.

yahoostockdata contains yahoo prices per day , i'd add number of shares per date depending on actual information available in incomestatement specific date.

when running query (without update) numbers want. except, when adding update statement, error message: suquery returned more 1 value.

msg 512, level 16, state 1, line 1 subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. statement has been terminated.

can me solve issue? had @ related questions, not find answer. thank in advance. below code i'm using:

update yahoostockdata set numberofshares = (select [weighted average shares outstanding (diluted)]    (select *,row_number() on (partition derived_1.morningstarticker,              derived_1.[date] order derived_1.asofdate desc) rn          (select yahoostockdata.yahooticker, incomestatement.morningstarticker,                yahoostockdata.[date], asofdate,                 incomestatement.[weighted average shares outstanding (diluted)]                incomestatement inner join                   yahoostockdata on incomestatement.morningstarticker = yahoostockdata.morningstarticker           yahoostockdata.[date] >= asofdate) derived_1) derived_2     rn = 1) 

try this

update set    numberofshares = b.[weighted average shares outstanding (diluted)]   yahoostockdata        join (select [weighted average shares outstanding (diluted)],                     derived_2.morningstarticker                (select *,                             row_number() on ( partition  derived_1.morningstarticker, derived_1.[date]                                 order derived_1.asofdate desc) rn                        (select yahoostockdata.yahooticker,                                     incomestatement.morningstarticker,                                     yahoostockdata.[date],                                     asofdate,                                     incomestatement.[weighted average shares outstanding (diluted)]                                incomestatement                                     inner join yahoostockdata                                             on incomestatement.morningstarticker = yahoostockdata.morningstarticker                               yahoostockdata.[date] >= asofdate) derived_1) derived_2               rn = 1) b          on a.morningstarticker = b.morningstarticker  

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -