sql - Concatenate multiple column into single in a resulted query -


i need in adding multiple column in single (db2) after resulted query

my resulted query looks like,

empi   hrs  mts  sds ------------------- sam    12   10   10 tukai  10   05   02 

now, want output instead:

empid   totaltimetaken ---------------------- sam     12:10:10 tukai   10:05:02 

first query:

select     empid     ,totalseconds/3600 hrs     ,(mod(totalseconds, 3600) /60) mts     ,(mod(totalseconds, 60)) sds      (select         sum(duration) totalseconds         ,empid      table      group empid) 

from above query result, want add columns: empid, hrs, mts, sds.

i used query not getting result. help...

select      tmp1.emp     ,('0'||(totalseconds.tmp1)/3600)||':'||     ('0'||(mod(totalseconds.tmp1),3600)/60) ':'||     mod(totalseconds.tmp1),60) totaltimetaken     ,tmp1.totalseconds    (select         empid emp,        sum(duration) totalseconds     table     group empid) tmp1 

this ibm db2.

you should using tmp1 prefix-

select tmp1.emp, tmp1.totalseconds,            ('0' || (tmp1.totalseconds) / 3600) || ':' ||            ('0' || (mod(tmp1.totalseconds, 3600) / 60) ':' ||            mod(tmp1.totalseconds, 60) totaltimetaken (select empid emp, sum(duration) totalseconds       table       group empid) tmp1 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -