Get distinct records if more than one select column

Hi,
I have a table .
ParentId
refid
TaskNo
[TaskOwner]
[UpdatedBy]
Remarks
Description
100
NULL
100
user2
user2
hi
hi
100
100
100.1
user1
user1
this 
this 
100
100.2
100.2.1
user2
user1
is 
is 
101
NULL
101
user1
user2
the 
the 
102
102
102.1
user2
user2
rem
desc
103
103.1
103.1.2
user1
user1
rem1
desc1
Previously I able to show parentid where refid is null , but now I would like to show 102,103 values also.
Desired result :
ParentId
refid
TaskNo
[TaskOwner]
[UpdatedBy]
Remarks
Description
100
NULL
100
user2
user2
hi
hi
101
NULL
101
user1
user2
the 
the 
102
102
102.1
user2
user2
rem
desc
103
103.1
103.1.2
user1
user1
rem1
desc1
Please help me to write query..
Thank you.

Thank you Visakh16..
I got solution ..
  seq=4 for the record is nothing but sql is partitioning records first and filtering .
If i move the filter inside and working is fine..
SELECT Seq,ParentId,refid,TaskNo,TaskOwner,UpdatedBy,Remarks
FROM
SELECT *,ROW_NUMBER() OVER (PARTITION BY ParentId ORDER BY refid) AS Seq
FROM [t_TaskMaster] WHERE STATUS NOT IN ('Deleted', 'Completed', 'Closed') AND [TaskOwner] = @UserName
AND UpdatedBy <> @UserName
)t
WHERE Seq=1
Filter should be inside only
As ROW_NUMBER logic should be applied only after filtering. otherwise you'll miss required records
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • RE: Getting multiple values from more than one multiple select popup window

    I have a button on a JSP of mine that when clicked creates a popup window (right now it is called popup.html) with a multiple select menu.
    My question is how do I get all the values selected from the menu into my JSP (sample.jsp) so that I can set each of the values for my bean.
    The other problem is that I have more than one select multiple menu.
    Please help if you can. Any advice or suggestions here would be greatly appreciated!
    Thank you!

    I realize that I can use request.getParameterValues to get the values selected from my html because I am passing them to the hidden inputs I have and then using the request.getParameterValues to get each of the values.
    MY PROBLEM IS WHAT IF I HAVE 4 MULTIPLE SELECTS??? How can I use the same html popup menu to get the values from the 4 different multiple selects????
    I look forward to your response.
    This code is from my JSP:
    <INPUT TYPE="TEXT" NAME="Field1" SIZE="15">
    <INPUT TYPE="hidden" name="F1Rad1">
    <INPUT TYPE="hidden" name="Permission">
    <input type=button name=choice onClick="window.open('optionPicker.html','popuppage','width=250,height=100');" value="Options"></TD>
    Here is my optionPicker.html code for the pop up menu:
    <html>
    <head>
    <script language="JavaScript">
    function sendValue(s)
    var boxSize= s.options[0].value;
    var restrict     = s.options[1].value;
    window.opener.document.addNewForm.F1Rad1.value = boxSize;
    window.opener.document.addNewForm.Permission.value = restrict;
    window.close();
    </script>
    </head>
    <body>
    <center>
    <form name=selectform>
    <select multiple name=selectmenu size="2">
    <option value="large">Large Text Input Area
    <option value="restrict">Restricted Access
    </select>
    <p></p>
    <input type=button value="Select Option(s) For Field" onClick="sendValue(this.form.selectmenu);">
    </form>
    </center>
    </body>
    </html>

  • Get the data with more than one of the desired value

    Hi,
    I need to pull the records with more than one value of 'Other' on the delivery days fields.
    The delivery fields are mon,tue,wed,thu,fri and sat that tells the where the item will be delivered. The value can be Home, Work, or Other.
    Here is the Sample data:
    cust_id: 123
    item: newspaper
    mon: Home
    tue:Work
    wed: Other
    thu: Home
    fri: Other
    sat: Other
    And here is my query so far.
    select
    cust_id,
    item,
    mon,
    tue,
    wed,
    thu,
    fri,
    sat,
    sum(case when (del_mon = 'O' or del_tue ='O' or del_wed ='O' or del_thu ='O' or del_fri ='O' or del_sat='O') then 1
    else 0 end) as day_ctr
    from customer
    Could you please help me with the right formula I need to get this?
    Thank you in advance..

    First
    DESC customer
    Second
    Can you explain what you are trying with
    sum(case when (del_mon = 'O' or del_tue ='O' or del_wed ='O' or del_thu ='O' or del_fri ='O' or del_sat='O') then 1 else 0 end) as day_ctr
    Third
    Usually it's helpful a example of the result you want...
    Perhaps you want this
    select DECODE(mon,1,(select distinct mon from customer), 'OTHER') mon,
            DECODE(tue,1,(select distinct tue from customer), 'OTHER') tue,
            DECODE(wed,1,(select distinct wed from customer), 'OTHER') wed,
            DECODE(thu,1,(select distinct thu from customer), 'OTHER') thu,
            DECODE(fri,1,(select distinct fri from customer), 'OTHER') fri,
            DECODE(sat,1,(select distinct sat from customer), 'OTHER') sat from
    select
    COUNT(DISTINCT mon) mon,
    COUNT(DISTINCT tue) tue,
    COUNT(DISTINCT wed) wed,
    COUNT(DISTINCT thu) thu,
    COUNT(DISTINCT fri) fri,
    COUNT(DISTINCT sat ) sat
    from customer
    )

  • Can i record with more than one audio interface

    I need to record 16 tracks, I have two different audio iterface, in GarageBand i can only find one of them, if i go to prefrenses-audio, I can set any of them as my audio interface, but only one at the time.
    Any tips to how I can use bouth simultanious? Cubase, Logic mabye, GarageBand no can do? :-)

    josteinfromoslo wrote:
     can i record with more than one audio interface
    yes, create an aggregate device:
    http://www.bulletsandbones.com/GB/Tutorials.html#allaboutaggregatedevices
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    josteinfromoslo wrote:
    I need to record 16 tracks
    GB can only record 8 tracks at a time, however that is 16 channels, so with some extra effort you can get the outcome you desire, see the second tip here:
    http://www.bulletsandbones.com/GB/TricksHacks.html

  • More than one selects in a function

    Hi All,
    Is it that there can not be more than one selects in a function?What is the work around for this thing?
    Regards,
    Amit.

    Hi Krystian Zieja ,
    Thanks for responding. I do not know what was going wrong but now it is working fine.
    The problem is that I was not able to compile a function with two select statements in it. If I could comment one of the select statements it was getting compiled. But now it is getting compiled with both the selects.
    Now since we are at it can you solve another of my problem. I want to see the output of my function. If I write DBMS_OUTPUT.PUT_LINE statements in it I am not able to see the output. Is there anyway that I can call my function and it can show the output on the screen.
    I am using Benthic Golden 32 editor. Is there any way in it that I can call my function from it ?
    Regards,
    Amit.

  • Combo box or similar where more than one selection can be made

    Hi. I need to create a combo box field or similar where more than one selection can be made. Does anyone know if this is possible? I know this can be done with the check box tool but the client wants a drop down box. Thanks in advance.

    I don't quite understand some of this but of course you can bind more than one object into the RMI Registry. If you use different names the clients will use the object corresponding to whatever name they looked up. If you rebind different objects to the same name, the clients will use the object that was there at the time they did the lookup.
    Clustering is a problem for RMI/JRMP because stubs are not location-transparent: they refer to the originating JVM. If you need this kind of functionality I would use RMI/IIOP and do some CORBA magic in the ORBs at both the clustered servers. CORBA references are location-transparent so a service can be logically 'moved' from one JVM to another.

  • Spatial index creation for table with more than one geometry columns?

    I have table with more than one geometry columns.
    I'v added in user_sdo_geom_metadata table record for every column in the table.
    When I try to create spatial indexes over geometry columns in the table - i get error message:
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA table
    ORA-13203: failed to read USER_SDO_GEOM_METADATA table
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 8
    ORA-06512: at line 1
    What is the the solution?

    I'v got errors in my user_sdo_geom_metadata.
    The problem does not exists!

  • More than one SDO_GEOMETRY columns in one Oracle 8i spatial table

    I have a spatial table as follows:
    CREATE TABLE TEST(
    ID VARCHAR2(255) NOT NULL,
    POINT MDSYS.SDO_GEOMETRY,
    LINE MDSYS.SDO_GEOMETRY,
    POLYGON MDSYS.SDO_GEOMETRY,
    PRIMARY KEY(ID));
    Is it a good practice to have more than one SDO_GEOMETRY columns
    in one spatial table? What are the drawbacks if any to have a
    spatial with more than one layer?

    I have one question about more than one SDO_GEOMETRY columns
    in one table in Oracle 8.1.7. When I wanted to create two
    spatial indices for this table, every time I got some error.
    Can anyone tell me how to figure it out?
    Thanks very much,
    Fan Fan,
    You need to insert metadata record before creating spatial
    indices.
    Try the following:
    REM USER_SDO_GEOM_METADATA :
    REM insert a row for the geom layer for TEST TEST2 tables
    REM
    INSERT INTO USER_SDO_GEOM_METADATA
    ( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES ('TEST', 'POINT', MDSYS.SDO_DIM_ARRAY
    (MDSYS.SDO_DIM_ELEMENT('LON', -180,
    180, .000005),MDSYS.SDO_DIM_ELEMENT('LAT', -90, 90, .000005)),
    NULL);
    INSERT INTO USER_SDO_GEOM_METADATA
    ( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES ('TEST', 'LINE', MDSYS.SDO_DIM_ARRAY
    (MDSYS.SDO_DIM_ELEMENT('LON', -180,
    180, .000005),MDSYS.SDO_DIM_ELEMENT('LAT', -90, 90, .000005)),
    NULL);
    INSERT INTO USER_SDO_GEOM_METADATA
    ( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES ('TEST', 'POLYGON', MDSYS.SDO_DIM_ARRAY
    (MDSYS.SDO_DIM_ELEMENT('LON', -180,
    180, .000005),MDSYS.SDO_DIM_ELEMENT('LAT', -90, 90, .000005)),
    NULL);
    REM create a spatial index based on TRAFFIC.GEOM
    REM
    REM
    CREATE INDEX TEST_G_POINT_IDX ON TEST(POINT) INDEXTYPE IS
    MDSYS.SPATIAL_INDEX;
    CREATE INDEX TEST_G_LINE_IDX ON TEST(LINE) INDEXTYPE IS
    MDSYS.SPATIAL_INDEX;
    CREATE INDEX TEST_G_POLYGON_IDX ON TEST(POLYGON) INDEXTYPE IS
    MDSYS.SPATIAL_INDEX;

  • How to get the contents of more than one comments of human task?

    The human task have more than one comments. I use the following functions to get the contents but still only get the first comment. Append function only returns the first comment.
    How to get all conents of comments?
    <while name="While_1"
    condition="bpws:getVariableData('Variable_int_i')&lt;number(bpws:getVariableData('Variable_comment_node'))">
    <sequence name="Sequence_3">
    <sequence name="Sequence_3">
    <assign name="Assign_7">
    <copy>
    <from expression="string(bpws:getVariableData('single_approve_1_globalVariable','payload','/task:task/task:userComment/task:comment'))"/>
    <to variable="Variable_comment_string"/>
    </copy>
    </assign>
    <assign name="Assign_6">
    <copy>
    <from expression="bpws:getVariableData('Variable_int_i')+1"/>
    <to variable="Variable_int_i"/>
    </copy>
    </assign>
    </sequence>
    </sequence>
    </while>

    You also have to test the value:
    REPORT ztest MESSAGE-ID 00.
    DATA: BEGIN OF itab OCCURS 0,
            f1 TYPE i,
            f2 TYPE i,
            f3 TYPE i,
            f4 TYPE i,
          END OF itab.
    DATA: sel_field(20),
          value TYPE i.
    DO 5 TIMES.
      itab-f1 = sy-index.
      itab-f2 = sy-index + 10.
      itab-f3 = sy-index + 20.
      itab-f4 = sy-index + 30.
      APPEND itab.
    ENDDO.
    LOOP AT itab.
      WRITE: /001 itab-f1, itab-f2, itab-f3, itab-f4.
      HIDE itab.
      CLEAR itab.
    ENDLOOP.
    AT LINE-SELECTION.
      CLEAR: sel_field,
             value.
      GET CURSOR FIELD sel_field.
      IF sy-subrc = 0.
        CASE sel_field.
          WHEN 'ITAB-F1'.
            value = itab-f1.
          WHEN 'ITAB-F2'.
            value = itab-f2.
          WHEN 'ITAB-F3'.
            value = itab-f3.
          WHEN 'ITAB-F4'.
            value = itab-f4.
        ENDCASE.
        MESSAGE s001 WITH 'Value of' sel_field 'is' value.
      ELSE.
        MESSAGE s001 WITH 'Invalid field selected'.
      ENDIF.
    Rob

  • Do you get extra storage for more than one device

    Do you get extra iCloud storage for more than one device

    No. The free storage is currently per Apple ID rather than per device.

  • How do I set or get firefox to print more than one all pages the print using verizon emails is there a setting to change I have been told by verizon techs it is not my printer

    when opening an email using verizon emails I can only print one page. I have checked an I do not have a printer or computer problem because the printer prints more than one page with others such as gmail. We feel there is a print setting in firefox that needs to be changed. How do I change this??

    That is usually caused by a few different Bugs in Firefox, which seem to be fixed in the Firefox 4.0 betas.

  • ADF Table with more than one TableSelectMany column

    Does anyone know how to add more than one TableSelectMany component to a table? So, basically I'm trying to have two checkboxes for each row in the table
    thanks,
    Eric

    Eric,
    the TableSelectMany column is element of the selection facade which only takes one element.
    To create additional checkboxes, you can - of course - add an additional table column to the table and add a checkbox to it
    Frank

  • Checkbox with more than one display column.

    Hi.
    I have a checkbox item which I reference in a process (stored procedure) in my page. I'd like to display more than one field for the item, in different columns.
    The lov query allows only 2 fields, the display value and the return value.
    For now I just concatenate the 2 display fields, but I would like to display them in 2 different columns.
    Is this possible?
    My other option would be to use a report and set the item type to a simple checkbox. Is it possible then to reference the values of the report checkbox in my process ?
    Thanks in advance.

    Any ideas anyone?

  • How to retrieve unique records with more than one column

    I have a table sps_prod as described below -
    POGNAME VARCHAR2(1500)
    INDEX#VERSION VARCHAR2(200)
    POG_MODEL_STATUS VARCHAR2(100)
    POG_LAYOUT_TYPE VARCHAR2(500)
    POG_MARKET_SPECIFIC VARCHAR2(500)
    POG_CONTACT_NUMBER VARCHAR2(100)
    AREA_SUPPORTED VARCHAR2(500)
    POG_COMMENTS VARCHAR2(1500)
    POG_FOOTER_COMMENTS VARCHAR2(1500)
    POG_ELECTRICAL_LIST_1 VARCHAR2(1500)
    POG_ELECTRICAL_LIST_2 VARCHAR2(1500)
    POG_CARPENTRY_1 VARCHAR2(1500)
    POG_CARPENTRY_2 VARCHAR2(1500)
    INSTALLATION_INSTRUCTION_1 VARCHAR2(1500)
    INSTALLATION_INSTRUCTION_2 VARCHAR2(1500)
    FIXTURE_REORDER_NUMBER VARCHAR2(200)
    FIXTURE_ID VARCHAR2(200)
    FIXTURE_NAME VARCHAR2(500)
    FIXTURE_IMAGE VARCHAR2(500)
    PART_REORDER_NUMBER_9 VARCHAR2(500)
    PART_FIXTURE_ID_9 VARCHAR2(500)
    PART_FIXTURE_NAME_9 VARCHAR2(500)
    PART_FIXTURE_IMAGE_9 VARCHAR2(500)
    UPC VARCHAR2(50)
    ITEM_NUMBER VARCHAR2(50)
    DESCRIPTION VARCHAR2(700)
    MERCH_TYPE VARCHAR2(20)
    HEIGHT VARCHAR2(100)
    WIDTH VARCHAR2(100)
    DEPTH VARCHAR2(100)
    CREATE_TS DATE
    There are 4 millions records in it and many with the same combination of POGName,Index#Version,POG_Model_Status,POG_Layout_Type,POG_Market_Specific, POG_Contact_Number and Fixture_Name. How do I retrive records with all the columns above but with unique fixture_name and reorder_number combination. There are no keys defined on the table.
    I guess this is a simple problem but the fact that I am trying to retrieve all the columns is stumbling me.
    Thanks in advance.

    Hi,
    Sanders_2503 wrote:
    ... There are 4 millions records in it and many with the same combination of POGName,Index#Version,POG_Model_Status,POG_Layout_Type,POG_Market_Specific, POG_Contact_Number and Fixture_Name. How do I retrive records with all the columns above but with unique fixture_name and reorder_number combination. I don't see a column called reorder_number. Do you mean fixture_reorder_number or part_reorder_number_9?
    So you want only one row for each distinct combination of fixture_name and some other column (I'll assume that's fixture_reorder_number). Does it matter which row? They won't necessarily have the same values for the other columns.
    The query below returns the one with the first pogname (in sort order):
    WITH     got_r_num     AS
         SELECT  pogname, index#version, pog_model_status, pog_layout_type
         ,     pog_market_specific, pog_contact_number, fixture_name
         ,     ROW_NUMBER () OVER ( PARTITION BY  fixture_name
                                   ,                    fixture_reorder_number
                             ORDER BY        pogname
                           )         AS r_num
         FROM    sps_prod
    SELECT  pogname, index#version, pog_model_status, pog_layout_type
    ,     pog_market_specific, pog_contact_number, fixture_name
    FROM     got_r_num
    WHERE     r_num     = 1
    ;If there happens to be a tie (that is, two or more rows with the same fixture_name, fixture_number, and first pogname) then one of the will be chosen arbitrarily.
    Instead of "ORDER BY pogname", you can ORDER BY any other columns or expressions, but you must have an analytic ORDER BY clause. You can make it "ORDER BY NULL" if you really want to pcik an arbitrary row.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data (or a couple of examples of acceptable results).
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • *** I need to pull back just one record when more than one is listed.... **

    I have two (or more sometimes), there is a field called POC_type and then the POC_name, the POC_Name is different, but the rest of the records are the same, I only want to pull back the first record so I onlist one POC_Type, Name, ...
    Below is the code I have right nwo, but like I said it is pulling back multiples becase they have been entered into the systme twice (because of the diff POCs)...
    select distinct m1.*
    from  report_surv_ques_poc m1,
      (select investment_id, investment_acronym, investment_name, count(*)
      from  mv_surv_ques_poc
      where poc_type = 'Program Manager'
      and poc_status = 1
      group by investment_id, investment_acronym, investment_name
      having count(*) > 1) m2
    where m1.investment_id = m2.investment_id
      and m1.poc_type = 'Program Manager'
      and m1.poc_status = 1
      --and m1.investment_id = 14003
    order by m1.investment_id

    Thanks...
    I am using 10g.
    My code is now like...
    select distinct m1.*
    from  report_surv_ques_poc m1,
      (select investment_id, investment_acronym, investment_name, count(*)
      from  mv_surv_ques_poc
      where poc_type = 'Program Manager'
      and poc_status = 1
      group by investment_id, investment_acronym, investment_name
      having count(*) > 1) m2
    where m1.investment_id = m2.investment_id
      and m1.poc_type = 'Program Manager'
      and m1.poc_status = 1
      and m1.survey_id IN (67201, 67208)
    order by m1.survey_idshould it be like:
    WITH get_rows AS
       SELECT DISTICT ml.* ROW_NUMBER () OVER (ORDER BY m1.investment_id) AS rno
       FROM from  report_surv_ques_poc m1,
         (select investment_id, investment_acronym, investment_name, count(*)
            from  mv_surv_ques_poc
          where poc_type = 'Program Manager'
            and poc_status = 1
       group by investment_id, investment_acronym, investment_name
      having count(*) > 1) m2
      where m1.investment_id = m2.investment_id
      and m1.poc_type = 'Program Manager'
      and m1.poc_status = 1
    ) SELECT * FROM get_rows WHERE rno =1;cause that is not working ... I am sure I have something wrong....
    Kipp

Maybe you are looking for