Thread: Re: SQL Query Syntax help
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. -- Kind regards Jan
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 error.
ERROR: UNION types boolean and character cannot be matched
LINE 10: ..._ID","Critical_Decision" as col_Name, "Critical_... ^
SQL state: 42804
Character: 585
After applying the logic i need to take this data into the table.
can you please help me how to write the syntax in this case.
Thanks,
Srikanth B
From: Jan Kohnert <nospam001-lists@jan-kohnert.de>
Sent: Wed, 22 Jan 2020 17:11:56
To: pgsql-general@lists.postgresql.org
Subject: Re: SQL Query Syntax help
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.
--
Kind regards 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 error.
ERROR: UNION types boolean and character cannot be matched
LINE 10: ..._ID","Critical_Decision" as col_Name, "Critical_... ^
SQL state: 42804
Character: 585
After applying the logic i need to take this data into the table.
can you please help me how to write the syntax in this case.
Thanks,
Srikanth B
From: Jan Kohnert <nospam001-lists@jan-kohnert.de>
Sent: Wed, 22 Jan 2020 17:11:56
To: pgsql-general@lists.postgresql.org
Subject: Re: SQL Query Syntax help
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.
--
Kind regards Jan
On Wednesday, January 22, 2020, srikkanth <srikkanth16081991@rediffmail.com> 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 m applying the logic on this scenario i m getting the below error.
ERROR: UNION types boolean and character cannot be matched
LINE 10: ..._ID","Critical_Decision" as col_Name, "Critical_... ^
SQL state: 42804
Character: 585
After applying the logic i need to take this data into the table.
can you please help me how to write the syntax in this case.
Cast everything to text?
David J.