SQL query to search for the line that contains the identifier for each consecutive group

Hello

I'm on 11.2.0.3 Enterprise Edition.

I have a strange request here - do not know if this is possible without going to procedure...

Given these data of the sample:

create table test_status (
  status varchar2(10),
  revision_id number,
  revision_timestamp timestamp);

insert into test_status values ('PROPOSED', 1, systimestamp);
insert into test_status values ('PROPOSED', 2, systimestamp);
insert into test_status values ('PROPOSED', 3, systimestamp);
insert into test_status values ('ACTIVE', 4, systimestamp);
insert into test_status values ('ACTIVE', 5, systimestamp);
insert into test_status values ('PROPOSED', 6, systimestamp);
insert into test_status values ('PROPOSED', 7, systimestamp);
insert into test_status values ('ACTIVE', 8, systimestamp);
insert into test_status values ('ACTIVE', 9, systimestamp);
insert into test_status values ('FINISHED', 10, systimestamp);
insert into test_status values ('FINISHED', 11, systimestamp);
insert into test_status values ('FINISHED', 12, systimestamp);

Gives me:

SQL> select *
  2  from test_status
  3  order by revision_id;


STATUS     REVISION_ID REVISION_TIMESTAMP
---------- ----------- -----------------------------
PROPOSED             1 25-SEP-14 04.49.47.954000 PM
PROPOSED             2 25-SEP-14 04.49.47.962000 PM
PROPOSED             3 25-SEP-14 04.49.47.966000 PM
ACTIVE               4 25-SEP-14 04.49.47.969000 PM
ACTIVE               5 25-SEP-14 04.49.47.972000 PM
PROPOSED             6 25-SEP-14 04.49.47.976000 PM
PROPOSED             7 25-SEP-14 04.49.47.979000 PM
ACTIVE               8 25-SEP-14 04.49.47.982000 PM
ACTIVE               9 25-SEP-14 04.49.47.987000 PM
FINISHED            10 25-SEP-14 04.49.47.991000 PM
FINISHED            11 25-SEP-14 04.49.47.996000 PM
FINISHED            12 25-SEP-14 04.49.48.000000 PM


12 rows selected.
ws selected.

I want to get this result:

STATUS     REVISION_ID REVISION_TIMESTAMP
---------- ----------- ----------------------------
PROPOSED             3 25-SEP-14 04.49.47.966000 PM
ACTIVE               5 25-SEP-14 04.49.47.972000 PM
PROPOSED             7 25-SEP-14 04.49.47.979000 PM
ACTIVE               9 25-SEP-14 04.49.47.987000 PM
FINISHED            12 25-SEP-14 04.49.48.000000 PM

Then query the table ordered by Revision_Id, I would get the line containing the highest revision for each consecutive group of status values.  I am able to get the line containing the highest revision for each separate status, value, but I can't deal with the scenario where a state value reappears later.  In the case of the real world, it is a workflow and I need to take into account the fact that an element through the workflow may be redirected to the back front she proceeds forward again.

Hope it makes sense.

Thank you

John

Hi, John,.

John OToole (Dublin) wrote:

Hello

I'm on 11.2.0.3 Enterprise Edition.

I have a strange request here - do not know if this is possible without going to procedure...

...

Do not no stinkin' procedure:

WITH got_grp_id AS

(

SELECT the status, revision_id, revision_timestamp

ROW_NUMBER () OVER (ORDER BY revision_id)

-ROW_NUMBER () (PARTITION STATUS

ORDER BY revision_id

) AS grp_id

OF test_status

)

SELECT status

MAX (revision_id) AS revision_id

MAX (revision_timestamp) DUNGEON (DENSE_RANK LAST ORDER BY revision_id)

AS revision_timestamp

OF got_grp_id

GROUP BY status, grp_id

ORDER BY revision_id

;

For an explanation of the technique of Difference sets used here, see

Analytic Question lag and lead and/or

Re: Ranking of queries

Tags: Database

Similar Questions

  • Stuck on a sql query to search for records that have the same parent child records

    Oracle 10 g 2 Enterprise Edition.

    Hello

    I'm writing a logic to find records in a parent table, who have the same values in a child table.
    This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
    the problem is that I'm stuck.
    Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
    The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
    many managers.

    I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
    -- parent table
    CREATE TABLE manager (
     id      number primary key,
     name      varchar2(100));
    
    -- child table 
    CREATE TABLE employee (
     id          number primary key,
     name      varchar2(100));
    
    -- link table
    CREATE TABLE join_table (
     manager_id          NUMBER, 
     employee_id      NUMBER,
     CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id),
     CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id),
     CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) 
     );
    
    -- Insert some managers
    INSERT INTO manager (id, name) VALUES (1, 'John');
    INSERT INTO manager (id, name) VALUES (2, 'Bob');
    INSERT INTO manager (id, name) VALUES (3, 'Mary');
    INSERT INTO manager (id, name) VALUES (4, 'Sue');
    INSERT INTO manager (id, name) VALUES (5, 'Alan');
    INSERT INTO manager (id, name) VALUES (6, 'Mike');
    
    -- Insert some employees 
    INSERT INTO employee (id, name) VALUES (101, 'Paul');
    INSERT INTO employee (id, name) VALUES (102, 'Simon');
    INSERT INTO employee (id, name) VALUES (103, 'Ken');
    INSERT INTO employee (id, name) VALUES (104, 'Kevin');
    INSERT INTO employee (id, name) VALUES (105, 'Jack');
    INSERT INTO employee (id, name) VALUES (106, 'Jennifer');
    INSERT INTO employee (id, name) VALUES (107, 'Tim');
    
    -- Insert the links
    -- John manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103);
    -- Bob manages Paul, Simon, Kevin, Jack
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105);
    -- Mary manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107);
    -- Sue manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107);
    -- Alan manages Paul, Simon, Ken, Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107);
    -- Mike manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103);
    
    -- For sanity
    CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
    If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.
    Answer should be Mike.
    If I ask for Manager of Mary, the answer should be Sue.

    This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
    SELECT DISTINCT m.name AS manager
    FROM manager m, join_table jt, employee e
    WHERE m.id = jt.manager_id
    AND jt.employee_id = e.id
    AND e.id IN (
         SELECT e.id
         FROM manager m, join_table jt, employee e
         WHERE m.id = jt.manager_id
         AND jt.employee_id = e.id
         AND m.name = 'John')
    ORDER BY 1;
    I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.
    Any ideas?
    BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.

    What about...

    WITH manager_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id
      AND   m.name = :P_MANAGER)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    ), all_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    )
    SELECT a.*
    FROM   manager_list m,
           all_list a
    WHERE  m.employees = a.employees
    

    Would be easier in 11g, but I do not have a facility here so this is based on 10g.

    See you soon

    Ben

  • SQL query to search for a single line

    Hi All-
    I have a requirement where I have to get the id who subscribe only to a single course based on data below.

    ID courses
    103812 CFH
    102968 REP
    103812 DFH
    DFH 102968
    103071 DFH
    CFH 102968

    CREATE TABLE classes
    (IDENTIFICATION NUMBER,
    course VARCHAR2 (3));

    insert into class values (103812, "CFH");
    insert into class values (102968, "REP");
    insert into class values (103812, "DFH");
    insert into class values (102968, "DFH");
    insert into class values (103071, "DFH");
    insert into class values (102968, "CFH");

    SELECT THE ID
    IN THE COURSE OF
    GROUP BY ID
    AFTER HAVING COUNT (RACE) = 1;

  • Query to search for students by group ID

    Hello

    I have a table that has 2 columns student_id and Course_id.

    Examples of data

    Student_id Course_id
    -------------------------------
    1 > 1
    1 > 2
    1 > 3
    1 > 4
    2 > 1
    2 > 3
    3 > 1
    3 > 2
    3 > 4
    I want to find students who have completed all course 1,3,4.

    Try again with the following query.

    WITH T AS (SELECT 1 stu_id ,     1 stu_curs FROM DUAL
     UNION ALL
    SELECT 1 ,     2 FROM DUAL
     UNION ALL
    SELECT 1 ,     3 FROM DUAL
     UNION ALL
    SELECT 1 ,     4 FROM DUAL
     UNION ALL
    SELECT 2 ,     1 FROM DUAL
     UNION ALL
    SELECT 2 ,     3 FROM DUAL
     UNION ALL
    SELECT 3 ,     1 FROM DUAL
     UNION ALL
    SELECT 3 ,     2 FROM DUAL
     UNION ALL
    SELECT 3 ,     4 FROM DUAL
     )
    select stu_id from t where stu_curs in (1,3,4) group by stu_id having count(0) = 3;
    
  • query to search for the user of the application

    Hello

    What is the query to search for the user of the application in the sql command?

    I tried the query below
    select app_user from dual;
    app_user invalid identifier
    Thank you.

    Hello skud,
    The following SQL statement will give you the APP_USER which is an environmental variable in the APEX:

    SELECT v('APP_USER') FROM DUAL;
    

    See if it works. As I used the syntax given in the triggers to record audit trail above and it works fine.
    Kiran

    Published by: chubby Kiran June 11, 2011 04:08

    Published by: chubby Kiran June 11, 2011 04:09

  • [JS, ID5 SVR] select the line that contains vertically merged cells

    Hello

    I want to put the line type lines that contains vertically merged cells. Example of lines containing merged cells:




























    When a line defined as myTable.rows [1], it returns an error. How to get to the second and third rows.

    Best regards, Sjoerd

    How simple it can be:

    var myDoc = app.activeDocument;
    
    var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
    
    for (i=0;i
    

    I'm a rookie, that's for sure...

  • whenever I type in the google box to search for each letter i firefox type which application I would like to use to open this file, this is so embarrassing, how to stop this?

    whenever I type in the google box to search for each letter i firefox type which application I would like to use to open this file, this is so embarrassing, how to stop this?

    You are welcome

    Can you tell us which extension caused your problem?

  • Query to search for users based on the State of the resource

    Hi all

    I'm working on version 9 x IOM. I need to find all the users of a resource that is in "Ready" status in the profile of their resources

    Let say resource Genetiquea is here and for some users of the status of this resource in their resources profile is in "ready". I want to get these users.

    Melyssa, help me with this SQL query.

    Thank you
    Madhu

    Try this query:
    Select usr.usr_login, obj.obj_name, ost.ost_status, usr, obj, obi, Ouedraogo, ost where usr.usr_key = oiu.usr_key and obi.obi_key = oiu.obi_key and obi.obj_key = obj.obj_key and ost.ost_key = oiu.ost_key and obj.obj_name =''

    You can add: and ost.ost_status = to find the status as well.

    Kind regards
    GP

  • Production PL/SQL query: can not find the error

    I have a PL/SQL which produces a query for me, which is used to fill out a report. I use this to supply a filter/search form. Since I want to only filter using xxx movies WHERE = yyy when yyy actually has something else NULL, I use a PL/SQL script in the query I need to produce. However, it does not work as expected and I can't understand why. Here is my code:
    DECLARE
      query VARCHAR(1000);
    BEGIN
      query := 'SELECT * FROM F_OBJEKTE WHERE 1=1 ';
      IF :P15_REGION != null THEN
        query := query || 'AND REGION = :P15_REGION ';
      END IF; 
      RETURN query;
    END;
    However, the report still contains all lines, as if P15_REGION has not been defined - and so I guess that the script never enters the IF part. Everyone around who can enlighten me, why it is?

    Just another little thing: is there a way I can print debugging messages I see when I press the "Debug" button on the lower bar of APEX? It would help a lot of debugging such PL/SQL functions.

    Try changing

    IF: P15_REGION! = null THEN

    TO

    IF: P15_REGION is not null THEN

  • SQL - last selection query save values for each date in term

    Hello

    Can anyone help me please with my problem.

    I'm trying to get the last balance recorded for each day of specific box (1 or 2) in a given period of days of the database ms access using ADOTool.

    I'm trying to get this information with SQL query but so far without success.

    My table looks like this:

    Name of the table: TestTable

    Date         Time      Location  Box  Balance
    20.10.2014.  06:00:00     1       1    345
    20.10.2014.  12:00:00     1       1    7356
    20.10.2014.  18:45:00     1       1    5678
    20.10.2014.  23:54:00     1       1    9845
    20.10.2014.  06:00:02     1       2    35
    20.10.2014.  12:00:04     1       2    756
    20.10.2014.  18:45:06     1       2    578
    20.10.2014.  23:54:10     1       2    845
    21.10.2014.  06:00:00     1       1    34
    21.10.2014.  12:05:03     1       1    5789
    21.10.2014.  15:00:34     1       1    1237
    21.10.2014.  06:00:00     1       2    374
    21.10.2014.  12:05:03     1       2    54789
    21.10.2014.  15:00:34     1       2    13237
    22.10.2014.  06:00:00     1       1    8562
    22.10.2014.  10:00:00     1       1    1234
    22.10.2014.  17:03:45     1       1    3415
    22.10.2014.  22:00:00     1       1    6742
    22.10.2014.  06:00:05     1       2    562
    22.10.2014.  10:00:16     1       2    123
    22.10.2014.  17:03:50     1       2    415
    22.10.2014.  22:00:10     1       2    642
    23.10.2014.  06:00:00     1       1    9876
    23.10.2014.  09:13:00     1       1    223
    23.10.2014.  13:50:17     1       1    7768
    23.10.2014.  19:47:40     1       1    3456
    23.10.2014.  21:30:00     1       1    789
    23.10.2014.  23:57:12     1       1    25
    23.10.2014.  06:00:07     1       2    976
    23.10.2014.  09:13:45     1       2    223
    23.10.2014.  13:50:40     1       2    78
    23.10.2014.  19:47:55     1       2    346
    23.10.2014.  21:30:03     1       2    89
    23.10.2014.  23:57:18     1       2    25
    24.10.2014.  06:00:55     1       1    346
    24.10.2014.  12:30:22     1       1    8329
    24.10.2014.  23:50:19     1       1    2225
    24.10.2014.  06:01:00     1       2    3546
    24.10.2014.  12:30:26     1       2    89
    24.10.2014.  23:51:10     1       2    25
    ...
    

    Let's say that the period is 21.10.2014. -23.10.2014. and I want to get the last balance recorded for zone 1. for each day. The result should look like this:

    Date         Time      Location  Box  Balance
    21.10.2014.  15:00:34     1       1    1237
    22.10.2014.  22:00:00     1       1    6742
    23.10.2014.  23:57:12     1       1    25
    

    So far, I managed to write a query that gives me the balance so that a SINGLE date (date more time in the table), but I need balance for EACH date in a specific period.

    My incorrect code (has not managed to implement "BETWEEN" for the dates...):

    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    

    TNX!

    NP

    Here's the correct query (just copy - paste):

    SELECT
    T1.Date,
    T1.Time,
    T1.Location,
    T1.Box,
    T1.Balance
    FROM TestTable T1
    INNER JOIN (
    SELECT
    MAX(Time) AS Max_Time
    FROM TestTable
    WHERE Location=1 AND Box=1 AND Date BETWEEN #10/27/2014# AND #11/1/2014#
    GROUP BY Date) T2
    ON T1.Time=T2.Max_Time;
    

    The problem is in the SELECTION within the INNER JOIN. This SELECTION selects the time max for each date, because we want this and then the entire table, we choose filelds we want, but now we have only fields with the time max.

    Here is a really good explanation of INNER JOIN if anyone is interested--> JOINT INTERNAL

    Peace!

  • SQL query to meet all the conditions.

    ID of country client_name

    a                      india        1

    a                     US            1

    oneWE1

    b                      india         1

    c                      india        1

    c                      india         1

    c                      india         1

    c                     us             1

    c                    US            1

    If I do a count if the id of group by client_name and country column I'll get value like that...

    client_name country count (id)

    a                  india          1

    a                    US          2

    b                  india          1

    c                  india          3

    c                   US           2

    Condition of the obligation:

    (1) if the customer is in effect in several countries then show that the customer and country having count (id) > 2, (over the case it will be customer = 'b' and country India, country will be us skip)

    (2) if the customer is does not exist in several countries then show that client and default country (in above cases it will be customer = 'b') while count (id) is less than 2., we show him...

    Catch for me is :-also, we should not ignore any customer... so, as in a. customer... as count (id) for the two countries is not more than 2... so, as per above logic... this client will ignore if we apply only above two conditions

    but we need to show the customer in this case... and take the two value... so my end result I need will be:

    customer country

    a India

    a                    US

    b the India

    c India

    Please suggest the query to achieve even... I am able to get the query that meets condition 1 and condition 2. but failure to have taken also in request... so in my query output is all above, except customer one is ignored

    Thank you very much!

    Hello

    I think I see.  You want to display the lines of 'best' available for any client, where the lines with a COUNT (*) 2 > are 'better' than the lines with COUNT (*) <= 2. ="" if="" a="" client="" has="" any="" rows="" with="" count="" (*)="">2, then to display the lines were COUNT (*) > 2, but if all the lines for a customer have COUNT (*)<= 2,="" then="" those="" are="" the="" "best"="" rows="" available,="" so="" you="" want="" to="" show="" them. ="" how="" many="" different="" countries="" a="" client="" is="" related="" to="" doesn't="">

    I always CREATE TABLE and INSERT statements for your sample data, so I'll we table scott.emp to illustrate.  Instead of customer and country, as at your table, we will use deptno and job.  This query:

    SELECT deptno, job

    AS cnt ACCOUNT (*)

    FROM scott.emp

    GROUP BY deptno, job

    ORDER BY deptno, cnt

    ;

    display the relevant data, i.e.:

    DEPTNO JOB CNT

    ---------- --------- ----------

    10. THE CHAIRMAN 1

    MANAGER 10 1

    10 1 CLERK

    20 MANAGER 1

    20 2 ANALYST

    20 CLERKS 2

    30 1 CLERK

    30 1 MANAGER

    30 4 SELLER

    But we don't want to show all the data.  We want to only show the best available for each deptno line type, where the lines with the cnt > 2 (let's call these lines of class 'A') are better then with the NTC<= 2="" (let's="" call="" these="" class="" 'b'="" rows.) ="" the="" output="" we="" want="">

    DEPTNO JOB CNT

    ---------- --------- ----------

    10. THE CHAIRMAN 1

    10 1 CLERK

    MANAGER 10 1

    20 CLERKS 2

    20 MANAGER 1

    20 2 ANALYST

    30 4 SELLER

    Deptnos 10 and 20 only have rows of 'B' class, if we want to display the lines of 'B' class for these deptnos.  DEPTNO 30 has at least 1 row of class 'A', so we only show the lines of 'A' class of deptno = 30.  This is an example of a Query of Top - N, and here's a way to do it:

    WITH got_r_num AS

    (

    SELECT deptno, job

    AS cnt ACCOUNT (*)

    DENSE_RANK () OVER (PARTITION BY deptno

    ORDER OF CASES

    WHEN COUNT (*) > 2

    THEN "A".

    OF ANOTHER 'B '.

    END

    ) AS r_num

    FROM scott.emp

    GROUP BY deptno, job

    )

    SELECT deptno, job, cnt

    OF got_r_num

    WHERE r_num = 1

    ;

  • How to search files of names that contain the dollar sign ($)?

    I typed "$" in the search box and all the files were returned. I tried------$ and no items found.

    Hello

    Use the wildcards * and?

    * means 'everything' or 'all '.

    ? means 'any character a' then? We hear every two characters and so on.

    So * $*. * would find all the names of file with a $ in the name with any extension.

    ?$*.? XE'd find filenames with characters 1 or not before the $ and with the
    extensions that contain characters 1 or not before a xe as .axe, .3xe or just in. XE.

    Tips for finding files
    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-finding-files

    How to use advanced search in Vista Options
    http://www.Vistax64.com/tutorials/75451-advanced-search.html

    How to restore the page button on the Start Menu after installing Vista SP1
    http://www.Vistax64.com/tutorials/145787-Search-start-menu-button-restore-after-SP1.html

    How to restore the context Menu item search after installing Vista SP1
    http://www.Vistax64.com/tutorials/134065-search-context-menu-item-restore-after-Vista-SP1.html

    How to create a shortcut on the desktop search in Vista
    http://www.Vistax64.com/tutorials/126499-search-desktop-shortcut.html

    ----------------------------------------------------------

    Win Key F opens advanced search

    Searching in Windows Vista, part 1
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-1-secrets-of-the-search-box

    Part 2
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-2-Start-menu-and-control-panel-search-tips

    Part 3
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-3-using-advanced-search-for-those-hard-to-find-files

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • SQL query to dynamically filter the records-need help

    Hello

    I have a table with the structure as below

    Create table T1
    (Number (5) ID,)
    Action Varchar2 (20)
    )


    Here's the table of contents at different points in time and please help me with a query that must dynamically discover the results according to the entries in the table.

    First Table contents

    1 pending
    2 waiting


    Result of the query must be

    1 pending
    2 waiting


    After an insert the Table of contents

    1 pending
    2 waiting
    3 ignored

    Result

    Nothing should be displayed


    After an insert the Table of contents
    1 pending
    2 waiting
    3 ignored
    4 ignored

    Result
    Nothing should be displayed

    After an insert the Table of contents
    1 pending
    2 waiting
    3 ignored
    4 ignored
    5 in queue

    Result
    5 in queue

    Thanks in advance!

    Best regards
    Sridhar

    Hi, Sridhar,

    So you want to show t1 lines that come after the last row with action = "Ignored", which means no output at all during the last row has action = "ignored". (A line with a given id is considered as ' after' a line with a lower id. The line with the highest id is considered the "last" line.)
    Is this fair?

    Here's one way:

    SELECT     *
    FROM     t1
    WHERE     id  > (
              SELECT  MAX (id)
              FROM     t1
              WHERE     action     = 'Ignored'
               )
    ;
    

    It's not assume this id is whole consecutive.

    If the id is not unique, what results do you want? There is a chance that the above query is already doing if this is not the case, it can probably be changed.

  • PL/SQL Query return function, adding the column links

    Hi all

    I'm working on a SQL report with the area type = function from PL/SQL Query to return
    All columns are generated dynamically based on my mapping table and a column of ID.
    So whenever the page is loaded, according to the ID mapping table returns a set of columns in a particular order.
    So not only the columns are dynamic, but the order of the columns varies also.
    But the first 1 column is standard (it doesn't come from the mapping table) and is coded in my pl/sql block hard.

    I'm fighting with the addition of a link to this column. The link must be a Javascript function which takes the parameters in the form of 2 columns in the mapping table.
    My pl/sql block is something like that...
    v_select := 'SELECT <g href=javascript:f_report1(#map_id#,#comments#)><img src=""></a> as report1, ';  // g=a
    v_cols := 'contains all columns from the mapping table based on a ID(hidden item)';
    v_from := 'FROM table';
    v_where := 'where condition is put in here';
    v_query := v_select||v_from||v_where;
    return v_query;
    Now, I'm not able to transmit the values of this #map_id # and #comments # correctly. I tried so many different combinations of channels, but could not make it work.

    I'm not sure that the order of this map_id and commentscolumn and therefore cannot connect through the report attributes.
    How can I go to a column value to the function?



    Thank you
    Dippy

    This should work if all goes well:

    v_select := q'[ SELECT '' as chart, ]';
    

    Published by: Dimitri Gielis on May 20, 2010 20:10

  • Consecutive date grouping and find the largest number of consecutive group

    Hi all

    I have given dates and I want to find the largest number of consecutive dates

    WIN_DATE_DATA

    2015-09-22

    2015-09-23

    2015-09-27

    2015-09-28

    2015-09-29

    2015-09-30

    2015-10-1


    In this example, there are 2 group of consecutive dates

    Group 1

    2015-09-22

    2015-09-23

    Group 2

    2015-09-27

    2015-09-28

    2015-09-29

    2015-09-30

    2015-10-1


    The OUTPUT should 5 which is the largest grouping of consecutive number.


    Thanks in advance for the help!




    Please take a look at the Community document: 101 PL/SQL: grouping sequence ranges (method Tabibitosan)

    will allow you to do.

Maybe you are looking for