SQL create a golden record from information in multiple rows -


for part sql robust , when hit dead wall, limitation. , stuck today.

what have in table ? what have in table ?

what output should ? what output should ?

what have got far ?

    temptable ( select     eid,     gender,     namelast,     namefirst,     namemiddle,     addrstreet1,     addrstreet2,     city,     state,     zip,     country,     ssn,     dob,     homephnareacode,     homephnnumber,     cellphnareacode,     cellphnnumber,     row_number() on (partition eid order modifieddate desc) rownum     [database].[dbo].[originaltable] )  update table [database].[dbo].[secondarytable] set col1, col2, col3.... select     eid,     max (gender)     gender,     max (namelast)   namelast,     max (namefirst)  namefirst,     max (namemiddle)     namemiddle,     max (addrstreet1)    addrstreet1,     max (addrstreet2)    addrstreet2,     max (city)   city,     max (state)  state,     max (zip)    zip,     max (country)    country,     max (ssn)    ssn,     max (dob)    dob,     max (homephnareacode)    homephnareacode,     max (homephnnumber)  homephnnumber,     max (cellphnareacode)    cellphnareacode,     max (cellphnnumber)  cellphnnumber     temptable group     eid 

this approach not seem work far. can of me right direction on how can done !?

if speed not important, try "naive" approach this

select (select top(1) firstcol yourtable firstcol not null order somecol) firstcol, (select top(1) secondcol yourtable secondcol not null order somecol) secondcol, (select top(1) thirdcol yourtable thirdcol not null order somecol) thirdcol  ... 

as far know, there no aggregate function allows "choose"/"select" value properties (like "not null") column when using group by. (plus wouldn't "aggregate" more)


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -