data warehouse - How to Correct the error in this SQL script (Database Using Azure Datawarehouse) -


i having hard time when try run script below. error messsage:

order clause not valid in views , inline functions

insert cc.s (     id,      encid,      a_name,      a_des,      a_type,      a_value,      d_create ) select      id,      encid,     'days_charge',     'days 43',     'int',     (         select              datediff(day,t_dis,a.ts_it)                       cc.enoun                       encid <> a.encid              , id=a.pe_id              , a_source='test'              , a.ts_admit > t_dis          order              tdischarge desc limit 1     ) attr_value,     getdate()      cc.s go 

in script, you're trying use select statement a_value. problem here select statement inline function. since inline function can't have order clause, have remove it.

insert cc.s(id, encid, a_name, a_des, a_type, a_value, d_create) select id, encid,'days_charge','days 43','int', (select datediff(day,t_dis,a.ts_it) cc.enoun encid<>a.encid , id=a.pe_id , a_source='test' , a.ts_admit>t_dis)         attr_value, getdate() cc.s go 

also make sure inline statement returns 1 value. since trying use order clause, may mean returns multiple results.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -