sql - Excel Pivot: pivot two columns in table without summarizing values -


i'm using query in excel following table:

select  "work_center"."eqno", "ud_data"."ud_cols_id", "work_center"."cuser1", "work_center"."cuser2", "work_center"."cuser3", "work_center"."cuser4",  "work_center"."cuser5", "work_center"."nuser1", "work_center"."nuser2", "work_center"."nuser3", "work_center"."nuser4", "work_center"."nuser5", "ud_data"."cuser"   "iqms"."ud_data" "ud_data"  full outer join "iqms"."work_center" "work_center"  on  "ud_data"."parent_id"="work_center"."id"    "work_center"."mfg_type"='injection'   ,  "ud_data"."ud_cols_id" not null order "work_center"."eqno" 

result

and following table: table

which has duplicates apart ud_cols_id(16,17,16,17...) , cuser(1000,test1,2000,test2.....)

desired result

but i've been trying in excel pivot column ud_cols_id on cuser(the last column in previous image) column, remove duplicate lines , this.

i've tried using excels pivot table can't seem prevent summarizing values e.g have ud_cols_id column headings, eqno , cuser values. keeps summarizing value field , there doesn't seem way not choose that? image

searching fixes keeps leading me examples want summarize data. , adding more values row , columns makes harder follow.

how should go doing this?

you're looking more this:

select    work_center.eqno,   work_center.cuser1,   work_center.cuser2,   work_center.cuser3,   work_center.cuser4,    work_center.cuser5,   work_center.nuser1,   work_center.nuser2,   work_center.nuser3,   work_center.nuser4,   work_center.nuser5,   ud_data_id_16.cuser id_16,   ud_data_id_17.cuser id_17       iqms.work_center work_center    inner join   iqms.ud_data ud_data_id_16     on     work_center.id=ud_data_id_16.parent_id ,     ud_data_id_16.ud_cols_id = 16    inner join   iqms.ud_data ud_data_id_17     on     work_center.id=ud_data_id_17.parent_id ,     ud_data_id_17.ud_cols_id = 17      work_center.mfg_type='injection' order    work_center.eqno 

why? well, ud_data has 2 rows per every work_center row, don't want both rows each associating every work_center row because double work_center rows. called cartesian product. gets worse if there x rows in work_center y rows in ud_data, number of duplicates becomes x * y

what need convert multiple rows per "thing" in ud_data single rows. either pivoting data in oracle, or joining table multiple times, , specifying reduces relationship 1:1 between ud_data , work_center.

a work_center row simplified column layout:

id, ud_data_id wc1, ud1 wc2, ud2 wc3, ud3 

a ud_data row set:

id, thing, otherthing ud1, apple, 100 ud1, android, 101 ud2, apple, hello ud2, android, goodbye ud3, apple, jan-17 ud3, android, dec-25 

the 2 ud rows per work centre row need become 1 row. either before join once, pivoting ud data rows this:

id, applething, androidthing ud1, 100, 101 ud2, hello, goodbye ud3, jan-17, dec25 

or join twice, selecting youre interested in each time (not syntactically correct regard id - no db accept this, that's not point being made):

work_center join ud_data on id=id   , ud_data.thing='apple' join ud_data on id=id   , ud_data.thing='android' 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -