Replace repeating lines with white and don't show the distinct values

Hi all

I have a SQL query that looks like this:

SELECT Item_id, item_details, category, group INC.
OF my_items
WHERE THE...

The results are as follows:

Item_id item_details category group

001 keyboard PC - 1 Grp1
001 keyboard PC - 2 Grp1
003 monitor PC - 1 Grp 1
003 monitor PC - 2 Grp 2


What I really want, it's like to have repeated as a draft values and keep only the distinct values. I want the output to be like this:

Item_id item_details category group

001 keyboard PC - 1 Grp1
PC-2
003 monitor PC - 1 Grp 1
PC - 2 Grp 2


Is there a way we can do that? Help, please

Here's a way using the Lag as mentioned by Tubby...

SQL> ed
Wrote file afiedt.buf

  1  with t as (select '001' as item_id, 'keyboard' as item_details, 'PC-1' as category, 'Grp1' as grp from dual union all
  2             select '001', 'keyboard', 'PC-2', 'Grp1' from dual union all
  3             select '003', 'monitor', 'PC-1', 'Grp1' from dual union all
  4             select '003', 'monitor', 'PC-2', 'Grp2' from dual)
  5  -- end of test data
  6  select decode(item_id, lag(item_id) over (partition by item_id order by category, grp), null, item_id) as item_id
  7        ,decode(item_details, lag(item_details) over (partition by item_id order by category, grp), null, item_details) as item_details
  8        ,decode(category, lag(category) over (partition by item_id order by category, grp), null, category) as category
  9        ,decode(grp, lag(grp) over (partition by item_id order by category, grp), null, grp) as grp
 10  from t
 11* order by t.item_id, t.category, t.grp
SQL> /

ITE ITEM_DET CATE GRP
--- -------- ---- ----
001 keyboard PC-1 Grp1
             PC-2
003 monitor  PC-1 Grp1
             PC-2 Grp2

SQL>

Tags: Database

Similar Questions

Maybe you are looking for

  • How to concatenate the string of normal worksheet to srting

    Hello I try to concatenate string worksheet to sring normal, but she cannot concatenate... here, I have attached my program for your firm .the support cannot be CONCATENATE.

  • Bad Virus infection. Need help please!

    My laptop (Dell MS 1350 operating Windows XP Pro, sp2) became infested with a very bad virus. The symptoms were:1. many programs did not more open with an error message "..." exe is not a valid win32 application ".2. no programs of virus removal, inc

  • The Deskjet D2360 driver installation error

    Came across the problem, try to install the driver for HP Deskjet D2360 (same error for small size and size driver CD) "The system does not have the specified path. and the screen thereafter I installed this driver on several other PCs with no proble

  • -files ctk.vmdk keep coming back.

    Hey guys,.I have problems with the ctk files - keep reappearing.  I am aware that this has to do with the change block Tracking (CBT) but I need it disabled.  With this licence, I am unable to properly use VMWARE JETTÉ TOOL COMMENTS BACK (get them). 

  • first_website_pt2 where is the total text box

    I'm doing this tutorial. Create your first website - part 2: creating the structure of the page. Adobe Developer ConnectionStep 8 of part 2 (the link above) says:In the text box the title of the Document at the top of your new document, type beat Bay