0
votes

I used Left Join in this
Table1 and Table2 has 1 row
Table3 has 2 row .
So the output is this
|.....................Table1....................||........Table2..........||.........Table3..........||
|ItemName...........|Brand............||UOM |Qty..|Price.||UOM.|Qty..|Price.||
|Short Bondpaper | HARDCOPY || PCS | 500 | 1100 || PCS | 100 | 1550||
|Short Bondpaper | HARDCOPY || PCS | 500 | 1100 || PCS | 100 | 2200||

Can I make it happen like this

|.....................Table1....................||........Table2..........||.........Table3..........||
|ItemName...........|Brand............||UOM |Qty..|Price.||UOM.|Qty..|Price.||
|Short Bondpaper | HARDCOPY || PCS | 500 | 1100 || PCS | 100 | 1550||
|Short Bondpaper | HARDCOPY || -...... | 0.....| 0...... || PCS | 100 | 2200||


OR like this?

|.....................Table1....................||........Table2..........||.........Table3..........||
|ItemName...........|Brand............||UOM |Qty..|Price.||UOM.|Qty..|Price.||
|Short Bondpaper | HARDCOPY || PCS | 500 | 1100 || PCS | 100 | 1550||
|NULL...................| NULL............||NULL|NULL|NULL|| PCS | 100 | 2200||

See Image

2
please specify the database - srp
add your query and sample input data - Jay Shankar Gupta
This is formatting data for display, usually done on the client. - dnoeth

2 Answers

0
votes

As there is no actual data and table structure it's not possible to provide actual query. Suggestion is to add a rank column in your query like

rank() over(partition by item_name, brand) 

and set the desired columns to NULLs if rank > 1;

0
votes

Arrangement of join should be like below:

Select * From Table3 
Left outer join Table2 on table3.colname=table2.colname
Left outer join Table1 on table3.colname=table1.colname;