Re: SQL Query Syntax help

2020-01-22 Thread David G. Johnston
On Wednesday, January 22, 2020, srikkanth wrote: > Hi Jan, > > Thanks for your input, it is working exactly what i want, but still i m > facing issue because in my table there are different data types they are 10 > to 15 columns are Boolean, one primary key, 140 columns are character. > > when i

Re: SQL Query Syntax help

2020-01-22 Thread srikkanth
Hi Jan,Thanks for your input, it is working exactly what i want, but still i m facing issue because in my table there are different data types they are 10 to 15 columns are Boolean, one primary key, 140 columns are character.when i m applying the logic on this scenario i m getting the below erro

Re: SQL Query Syntax help

2020-01-22 Thread Geoff Winkless
On Wed, 22 Jan 2020 at 11:00, srikkanth wrote: > Can you please help me in writing the syntax for the below mentioned table. > Suggest looking at the crosstab function. https://www.postgresql.org/docs/current/tablefunc.html crosstab(text source_sql, text category_sql) Produces a "pivot

Re: SQL Query Syntax help

2020-01-22 Thread Daniel Verite
srikkanth wrote: > Can you please help me in writing the syntax for the below mentioned This looks like an UNPIVOT operation. Here's a generic method that does this without having to specify the columns individually, with the help of json functions: SELECT ID, key, value FROM (SELECT

Re: SQL Query Syntax help

2020-01-22 Thread Jan Kohnert
Hi, Am Mittwoch, 22. Januar 2020, 12:00:45 CET schrieb srikkanth: [sniped HTML] something like select id, 'Col A' as "Col Name", "Col A" as "Col Value" from input union all select id, 'Col B' as "Col Name", "Col B" as "Col Value" from input ... order by 1, 2; should work. -- Kin

SQL Query Syntax help

2020-01-22 Thread srikkanth
Hi Team,Can you please help me in writing the syntax for the below mentioned table.Input : ID Col A Col B Col C Col D Col E Col F