How to add two columns as result in single query


Luther

I have the following query

select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des1
  from table  a inner join NOTES b on b.TBL_ROW_ID=a.emp_id
 where a.emp_id=56 and REF_NTE_TYP_ID=27

output 1

enter image description here

select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des2
  from table  a inner join NOTES b on b.TBL_ROW_ID=a.emp_id
 where a.emp_id=56 and REF_NTE_TYP_ID=28

output 2

enter image description here

Expected output:

enter image description here

Please help anyone.

DineshDB

Simple Aggregation(MAX)will help you get the expected output.

try this:

select a.emp_id,a.AUTH_TYPE
    ,MAX(CASE WHEN REF_NTE_TYP_ID=27 THEN b.NTE_TX END) as des1
    ,MAX(CASE WHEN REF_NTE_TYP_ID=28 THEN b.NTE_TX END) as des2
  from table  a inner join NOTES b on b.TBL_ROW_ID=a.emp_id
where a.emp_id=56 and REF_NTE_TYP_ID IN(27,28)
GROUP BY a.emp_id,a.AUTH_TYPE

Related


Rename two columns in netezza with single query

hand I am new to netezza. I need to know how to rename two columns with a single query. I tried, ALTER TABLE tabemp RENAME COLUMN salary to empsalary and name to empname; ALTER TABLE tabemp RENAME COLUMN salary to empsalary , name to empname; But none of the

PHP: Split query result into two columns

Sing I want to load contacts from a query, and while I've found some ways to split by row count, I want the results to be split into two columns (shown below) and they are a kind of clickable button. Describing query results as described below by using HTML or

How to add two columns as result in single query

Luther I have the following query select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des1 from table a inner join NOTES b on b.TBL_ROW_ID=a.emp_id where a.emp_id=56 and REF_NTE_TYP_ID=27 output 1 select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des2 from table a inner joi

How to add a single gradient color to two columns <td>?

jsjq-finder I have two table columns with data <td>, one is date and the other is time. Now I want to add a gradient color that starts with the date and ends with the time as shown in the image below. I am using Bootstrap 3.3.5, Javascript, Jquery. Is it possi

Add a single query result to a list

Jb pry I need to be able to search for a single name from ASP.NET DropDownListand add names playerwith that name to a list. My query looks like this: List<Player> players = new List<Player>(); var p1 = from p in db.Players where p.PlayerName == DropDo

Add a single query result to a list

Jb Pry I need to be able to search for a single name from ASP.NET DropDownListand add names playerwith that name to a list. My query looks like this: List<Player> players = new List<Player>(); var p1 = from p in db.Players where p.PlayerName == DropDo

How to add a single gradient color to two columns <td>?

jsjq-finder I have two table columns with data <td>, one is date and the other is time. Now I want to add a gradient color that starts with the date and ends with the time as shown in the image below. I am using Bootstrap 3.3.5, Javascript, Jquery. Is it possi

PHP: Split query result into two columns

Sing I want to load contacts from a query, and while I've found some ways to split by row count, I want the results to be split into two columns (shown below) and they are a kind of clickable button. Describing query results as described below by using HTML or

How to add two columns as result in single query

Luther I have the following query select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des1 from table a inner join NOTES b on b.TBL_ROW_ID=a.emp_id where a.emp_id=56 and REF_NTE_TYP_ID=27 output 1 select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des2 from table a inner joi

Rename two columns in netezza with single query

hand I am new to netezza. I need to know how to rename two columns with a single query. I tried, ALTER TABLE tabemp RENAME COLUMN salary to empsalary and name to empname; ALTER TABLE tabemp RENAME COLUMN salary to empsalary , name to empname; But none of the

AWK - Multiply two columns and add zeros to the result

Nas I have a csv file like this: Row 1,1,4.50, Row 2,8,0.30, Row 3,14,0.30, Row 4,2,2.50, Row 5,20,0.30, I want to multiply the second coulomb with the third and add the result as the fourth. I got this simple awk command: awk -F',' '{print $1 "," $2 "," $3 "

Add a single query result to a list

Jb Pry I need to be able to search for a single name from ASP.NET DropDownListand add names playerwith that name to a list. My query looks like this: List<Player> players = new List<Player>(); var p1 = from p in db.Players where p.PlayerName == DropDo

PHP: Split query result into two columns

Sing I want to load contacts from a query, and while I've found some ways to split by row count, I want the results to be split into two columns (shown below) and they are a kind of clickable button. Describing query results as described below by using HTML or

How to query one column and display the result as two columns

12Rev79 I have two sheets and I want to combine them into one sheet called "Mastersheet tab" This is my query in "Mastersheet tab" =Query({'Cut request '!A2:S;'Out sent '!A2:S},"Select Col1,Col2,Col4,Col3,Col10,Col13,Col17, Col19 where Col4 is not empty ",0) B

How to add two columns as result in single query

Luther I have the following query select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des1 from table a inner join NOTES b on b.TBL_ROW_ID=a.emp_id where a.emp_id=56 and REF_NTE_TYP_ID=27 output 1 select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des2 from table a inner joi

How to add two columns as result in single query

Luther I have the following query select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des1 from table a inner join NOTES b on b.TBL_ROW_ID=a.emp_id where a.emp_id=56 and REF_NTE_TYP_ID=27 output 1 select a.emp_id,a.AUTH_TYPE,b.NTE_TX as des2 from table a inner joi