September 14, 2017 at 11:10 am
dear experts,
Kindly help solving my problem..
I want to make the result rows become columnname
I have syntax like this
select * from ctlfw_app.dbo.ptbc_schema info
the results:
Databasename Schemaname Tablename Columnnames Columnseq
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP ENABLE_ALTERNATE_ACCOUNT_FLAG 31
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP ACCT_ALT_SUSPENSE 32
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP ALT_ACCT_SUSPENSE 33
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP UPDATE_CLOSING_FLAG 34
I'd like get the result in column "columnnames" become Columns.
So I create Pivot:
Select
columnnames
--select *
FROM CTLFW_APP.dbo.Ptbc_Dwh_Schema_Info as t
Pivot ( Max(t.columnseq)
For columnseq in ('')
) as p
where TABLEname ='SIM_17_001_ALTFLAG'
I want the result in "Columnnames" become Column,
but I Stuck...
thank you very much
September 14, 2017 at 11:19 am
unas_sasing - Thursday, September 14, 2017 11:10 AMdear experts,
Kindly help solving my problem..I want to make the result rows become columnname
I have syntax like this
select * from ctlfw_app.dbo.ptbc_schema info
the results:
Databasename Schemaname Tablename Columnnames Columnseq
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP ENABLE_ALTERNATE_ACCOUNT_FLAG 31
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP ACCT_ALT_SUSPENSE 32
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP ALT_ACCT_SUSPENSE 33
DWIM_INP IN_PROC INP_1011_1101_PSGL_BU_LEDGER_GROUP UPDATE_CLOSING_FLAG 34I'd like get the result in column "columnnames" become Columns.
So I create Pivot:
Select
columnnames
--select *
FROM CTLFW_APP.dbo.Ptbc_Dwh_Schema_Info as t
Pivot ( Max(t.columnseq)
For columnseq in ('')
) as p
where TABLEname ='SIM_17_001_ALTFLAG'I want the result in "Columnnames" become Column,
but I Stuck...
thank you very much
Red: where tablename=' INP_1011_1101_PSGL_BU_LEDGER_GROUP'
September 14, 2017 at 11:28 am
Read the following articles about dynamically pivoting tables:
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - SQLServerCentral
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - SQLServerCentral
The second one explains the dynamic part, but the first one explains the basic process.
September 14, 2017 at 8:10 pm
Luis Cazares - Thursday, September 14, 2017 11:28 AMRead the following articles about dynamically pivoting tables:
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - SQLServerCentral
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - SQLServerCentralThe second one explains the dynamic part, but the first one explains the basic process.
Hai Luis,,
thank you, i'll read it
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply