Analytic query to select next record

Hi all,
I would like to query the below two table match to ouput.
1.dev_wt 2.dev_map 3.Output Result
To help more clearance please see this image link : http://lh6.ggpht.com/_xL6eBqjW6Yo/TEqnSvlF_FI/AAAAAAAAB0U/i2sclnnaj6g/Untitled-3.jpg
1. dev_wt
PMS_COMP     PMS_I       PMS_PERF_D   PMS_WT   PMS_CREATION_D
BBOARD     GICEQGROSS    04/01/2001     30     04/05/2001
BBOARD     GICST_B       04/01/2001     5      04/05/2001
BBOARD     SBGS_B        04/01/2001     65     04/05/2001
BBOARD     GICEQGROSS    04/11/2001     30     04/15/2001
BBOARD     GICST_B       04/11/2001     5      04/15/2001
BBOARD     SBGS_B        04/11/2001     65     04/15/20012. dev_map
GS_CODE     GS_I_CODE    GS_I_ID  MD_ID   GS_START_DT    GS_END_DT
GICEQGROSS   CIWL        304       15     01/04/1998     31/03/2004
GICEQGROSS   CIWL        304       2     01/04/2004      31/03/9998
GICST_B      GICST_B     3707      15     01/04/2000     31/12/9998
SBGS_B       SBGS_B      2231      15     01/04/1992     30/09/2003
SBGS_B       SBGS_B      564       15     01/10/2003     31/12/9998I would like to match PMS_I = GS_CODE to retrieve GS_I_CODE and using analytic
query to find next record.
Because I need to select GICEQGROSS record of PMS_PERF_D date and next
GICEQGROSS record of PMS_PERF_D from dev_wt table and put GS_WT_FR and GS_WT_TO of Output result.
***Date is change to YYYYMMDD format
***PMS_WT is devided by 100
*3. Output Result*
GS_I_ID    PMS_COMP     GS_I_CODE     GS_WT_FR     GS_WT_TO     GS_I_CALC
304       BBOARD        CIWL          20010401     20010410     0.3
3707      BBOARD        GICST_B       20010401     20010410     0.05
5209      BBOARD        SBGS_B        20010401     20010410     0.65PMS_COMP is from dev_wt table
GS_I_CODE is from dev_map table join with dev_wt
GS_WT_FR is from dev_wt table of GS_START_DT
GS_WT_TO is from dev_wt table of next record GS_START_DT where PMS_I ='GICEQGROSS'
Now my difficulty is to select next record of PMS_PERF_D using analytic query. Below
is my query...
SELECT GS_I_ID, PMS_COMP, GS_I_CODE, GS_WT_FR, GS_WT_TO, GS_I_CALC
FROM dev_wt (
SELECT lead(PMS_PERF_D) over(partition by PMS_I order by PMS_PERF_D) as GS_WT_TO       
FROM dev_wt where PMS_I ='GICEQGROSS')
left join dev_map on PMS_I = GS_CODE ;Thanks
Edited by: WinZone on Jul 24, 2010 4:46 PM
Edited by: WinZone on Jul 24, 2010 4:50 PM

Hi,
This query should be fine:
SELECT DISTINCT t2.gs_i_id, pms_comp, t2.gs_i_code,
                TO_CHAR
                   (MIN (pms_perf_d) OVER (PARTITION BY pms_comp, pms_i),
                    'yyyymmdd'
                   ) gs_wt_fr,
                TO_CHAR
                   (MAX (pms_perf_d) OVER (PARTITION BY pms_comp, pms_i) - 1,
                    'yyyymmdd'
                   ) gs_wt_to,
                pms_wt / 100 gs_i_calc
           FROM dev_wt t1, dev_map t2
          WHERE t2.gs_code = t1.pms_iREM Same remark as odie: should be "2231" instead ...

Similar Messages

  • Query to select individual records similar to distinct

    The below query must return only one record for a account and not all the records. Additional columns cannot be added to the select statement.
    SELECT a.CODE, a.AMOUNT,a.DATEtime
    FROM PAYMENTS a,SB b
    WHERE a.TYPE = 'X'
    AND A.CODE=B.CODE
    AND A.ACCT=B.ACCT
    this is the sample output.
    123     5000     01/01/2005
    123     4500     01/01/2005 (Not required to display)
    458     74100     01/01/2005
    748     4744     01/01/2005
    411     4588     01/01/2005
    411     7488     01/01/2005 (Not required to display)
    thanks in advance for your help.

    Hi,
    Satya's Query didn't work because only ROW_NUMBER was misspelled.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH T as (SELECT 123 Code, 5000 Amount, '01/01/2005' DateTime FROM DUAL UNION ALL
      2  SELECT 123, 4500, '01/01/2005'  FROM DUAL UNION ALL
      3  SELECT 458, 74100, '01/01/2005'  FROM DUAL UNION ALL
      4  SELECT 748, 4744, '01/01/2005'  FROM DUAL UNION ALL
      5  SELECT 411, 4588, '01/01/2005'  FROM DUAL UNION ALL
      6  SELECT 411, 7488, '01/01/2005'  FROM DUAL)
      7  SELECT * FROM (
      8  SELECT Code,Amount,DateTime, ROW_NUMBER() OVER( PARTITION BY Code ORDER BY Code) RN FROM t)
      9* WHERE RN = 1
    SQL> /
          CODE     AMOUNT DATETIME           RN
           123       5000 01/01/2005          1
           411       4588 01/01/2005          1
           458      74100 01/01/2005          1
           748       4744 01/01/2005          1
    SQL>Regards

  • Query to select all records in the database

    Hi,
    i am in big trouble please help me...
    unfortunately i did some modifications in live system due that system was stopped...
    now i want to know what are all changes i have done in the database....
    please give me the query to see all the records in the specified schema....
    not for one table. i cont specify the table names also..
    MY Question is for example if i want to search updated_by field in one table i will do like this
    select * from eiis_salesorder_hdr where updated_by = 'is20';
    like that only i want query to search in entire schema....
    Edited by: indra on Sep 17, 2011 8:58 AM

    indra wrote:
    Hi,
    i am in big trouble please help me...
    unfortunately i did some modifications in live system due that system was stopped...
    now i want to know what are all changes i have done in the database....
    please give me the query to see all the records in the specified schema....
    not for one table. i cont specify the table names also..if DML was done & no COMMIT was issued, then changes would be rolled back after system restart
    what EXACTLY was issued SQL?
    do as below so we can know complete Oracle version & OS name.
    Post via COPY & PASTE complete results of
    SELECT * from v$version;

  • Select query for every 1000 records

    Hi all ,
             Please help me in the issue . I am using select query Select * from table up to 1000 rows for acheving the records but i want this process to retrigger once the process of 1000 records is compleded again it needs to fetch the next 1000 records and process the same . I am changing the status of the processed records once it is processed . Can can one tell me how to retrigger the select query once the 1000 records are processes.
    Thanks in advance,

    Hi Eric,
                  After selecting the 1000 records, find the key value of the last record. Build up the range as GT. Again use the select query.
    For example,
    Select * into table lt_data from ztab
    where key in r_key
    up to 1000 rows.
    regards,
    Niyaz

  • Simplify the select query to get single record

    Please let me know what is wrong with my query.
    Max(p_received_date) is returning null columns too. But i need to have only null record per period, if there is date and null record for the same billing then return the date record. please check november and september records. september should return only 09/13/10 record but it is returning null record too. please help to get expected out put.
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc
    Actual
    Billing key Billing company periodbalance lastpayment date outs
    110631534073 November 2010 U-7052-C 270 Yes
    110631534073 November 2010 U-7052-C 690 Yes
    110631534073 November 2010 U-7052-C 66 Yes
    110461533197 October 2010 U-7052-C 4740 Yes
    110461533197 October 2010 U-7052-C 27000 Yes
    110461533197 October 2010 U-7052-C 0 No
    110251532527 September 2010 U-7052-C 0 09/13/10 No
    110251532527 September 2010 U-7052-C 0 No
    110251532527 September 2010 U-7052-C -18 09/13/10 No
    110251532484 August 2010 U-7052-C 0 09/13/10 No
    110251532484 August 2010 U-7052-C 2001 09/13/10 Yes
    110251532484 August 2010 U-7052-C 0 No
    Expectedoutput(need only following columns)Outs is outstanding balance
    Billing key Billing company l astpayment date outs
    110631534073 November 2010 U-7052-C Yes
    110461533197 October 2010 U-7052-C Yes
    110251532527 September 2010 U-7052-C 09/13/10 No
    110251532484 August 2010 U-7052-C 09/13/10 YES
    By using below query i am getting all output as NO. HOw to modify this query.
    SELECT company,
    billing,LastPaymentDate,
    CASE
    WHEN SUM (DECODE (outs, 'YES', 1, 0)) > 0 THEN 'YES'
    ELSE 'NO'
    END Outstanding
    FROM (
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc)
    GROUP BY company, billing,LastPaymentDate;
    Note:in the actual out put max(lastpayment date) is returing null values. if there is any date in one billing return that date only remove null example is september. in september it should return only 09/13/10 this date not null date. but if there is no other within one biling then consider that as null example november..
    Thanks,
    v

    Another solution is setting NLS_SORT to CI - case insensitive (or whatever_your_language_is_CI) and NLS_COMP to ANSI:
    SQL> with t as (
      2             select 'HARI' name from dual union all
      3             select 'Hari' name from dual union all
      4             select 'HaRi' name from dual
      5            )
      6  select  *
      7    from  t
      8    where name = 'hArI'
      9  /
    no rows selected
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> alter session set nls_comp=ansi
      2  /
    Session altered.
    SQL> with t as (
      2             select 'HARI' name from dual union all
      3             select 'Hari' name from dual union all
      4             select 'HaRi' name from dual
      5            )
      6  select  *
      7    from  t
      8    where name = 'hArI'
      9  /
    NAME
    HARI
    Hari
    HaRi
    SQL> SY.

  • Query for next record in a multiple records display

    Hi. I have a text item whose data block displays 10 records after post query. I want to put a query on the keyboard up and down button so that when i press the up or down arrow of the keyboard, the cursor moves to the next record and executes the post query trigger. I tried using the next_record command but the cursor remains on the first record and then tries to create a new record there instead of moving to the next record outputted by the initial post query trigger. I hope you get my point. Thanks

    Hi,
    I have a text item whose data block displays 10 records after post query. <b>I want to put a query on the keyboard up and down button so that when i press the up or down arrow of the keyboard</b>, the cursor moves to the next record and executes the post query trigger. I tried using the next_record command but the cursor remains on the first record and then tries to create a new record there instead of moving to the next record outputted by the initial post query trigger. I hope you get my point. You do not have to query again for moving cursor up and down. You have to use KEY-UP and KEY-DOWN with NEXT_RECORD and PREVIOUS_RECORD built-ins. Use FIRST_RECORD and LAST_RECORD for boundary conditions.
    Regards,

  • Execute query & next record

    hi all...
    i have a one block tabular style no of record display...5..i have a query execute....and i have a one button Next_record; query fetch all record from a table ..cursor is a first record..i want a when i have pressed a next record record button ...the query display next 6 to 10 record...

    And you did not try KEY-NXTSET or KEY-SCRDOWN?

  • I need a query that selects the amount of records for each day in a table.

    I need a query that selects the amount of records for each
    day in a table.
    Eg the result would be:
    date 1 14
    date 2 3
    etc
    Any ideas?

    sorted:
    SELECT count([commentID]),convert(varchar, dateAdded, 112)
    FROM COMMENTSgroup by convert(varchar, dateAdded,
    112)

  • How to select the next record

    Hi All,
    i have a table like below. i need the next record after the status_code = 5.
    pls help
    JOB
    job_id               prnt_job_id             status_code
    2282                 2281                        4
    2283                 2281                        4
    2284                 2281                        5
    2287                 2281                        2
    2289                 2281                        2next record after status_code = 5 is
    2287                 2281                        2

    SELECT next_job_id,
      next_prnt_job_id,
      next_status_code
    FROM
      ( WITH t1 AS
      ( SELECT 2282 job_id, 2281 prnt_job_id, 4 status_code FROM dual
      UNION ALL
      SELECT 2283, 2281, 4 FROM dual
      UNION ALL
      SELECT 2284, 2281, 5 FROM dual
      UNION ALL
      SELECT 2287, 2281, 2 FROM dual
      UNION ALL
      SELECT 2289, 2281, 2 FROM dual
    SELECT lead(job_id,1) over(order by rownum) next_job_id,
      job_id,
      lead(prnt_job_id,1) over(order by rownum) next_prnt_job_id,
      prnt_job_id,
      lead(status_code,1) over(order by rownum) next_status_code,
      status_code
    FROM t1
    WHERE status_code=5

  • Next record

    I'm using vb script. I'm making a quiz. I connect to a
    database for the questions and choices.
    I have a test page and a test processor page.
    On the test page I display the question and 4 choices. On the
    test processor page, it tallies up the score and redirects back to
    the test page. I'm using Responce.Redirect("testpage.asp") to go
    back to the test page.
    After submitting my answer and going back to the test page I
    want to go to the next record. How do I do that?

    Hi Gred,
    I did put the query of table, but there was nothing happened on the screen. At the bottom of the screen still show record 1/1.
    My query is as below :-
    DECLARE
    V_NO NUMBER := 0;
    vdevice varchar2(30);
    cursor c1 is
    select device
    from aic_std_cost_sell_price;
    Rec1 c1%ROWTYPE;
    begin     
    FOR rec1 IN C1 LOOP
    begin
    FIRST_RECORD;
    WHILE V_NO = 0 LOOP
    IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
    V_NO := 1;
    EXIT;
    ELSE
    NULL;
    END IF;
    NEXT_RECORD;
    END LOOP;
    END;
    END LOOP;
    RETURN;
    END;
    rgds
    Lim

  • Select one record per person from multiple conditions

    Perhaps been staring at this too long and making changes to try and gather the correct population, but can't seem to figure it out at the moment. Trying to determine logic to select one record per person. If person has more than one record would like to choose the record that matches the sequence priority which is:
    AND CASE WHEN ac.primary_program_ind = 'N'                                       --Existing Students who have a new program (Continuing Law and added Business)
                                   AND ac.academic_period_admitted = ac.academic_period
                                   AND ac.student_population <> 'V'
                                   AND ac.program is not null THEN 'Y'
                                WHEN ac.primary_program_ind = 'Y'                                        --Visitors (Each term considered new)
                                   AND ac.student_population = 'V'
                                   AND ac.academic_period_admitted is not null THEN 'Y'
                                WHEN ac.primary_program_ind = 'Y'                                        --Normal Cases
                                   AND ac.academic_period_admitted is not null THEN 'Y' --= ac.academic_period THEN 'Y'
                       END = 'Y' Meaning that if the person has records that meet more than one of the above cases, it should choose the record matching the First Case of the case statement. If the records do not meet the first case at all then look to see if it meets the second case and if it does choose that record, etc.
    Sample Data:
    SELECT 363 AS PERSON_UID, '1875' AS ID, '201140' AS ACADEMIC_PERIOD, '201040' AS ACADEMIC_PERIOD_ADMITTED, 'UG' AS STUDENT_LEVEL, '' AS EXIST_NEWPROG, 'Y' AS VISITORS, 'Y' AS NORMAL, 'V' AS STUDENT_POPULATION, 'Y' AS PRIMARY_PROGRAM_IND, 'LA' AS PROGRAM FROM DUAL
    UNION SELECT 852, '1962', '201130', '201040', 'GR', '', '', 'Y', 'C', 'Y', 'MS'  FROM DUAL
    UNION SELECT 852, '1962', '201140', '201140', 'GR', 'Y', '', '', 'G', 'N', 'MBA' FROM DUAL
    UNION SELECT 852, '1962', '201140', '201040', 'GR', '', '', 'Y', 'G', 'Y', 'MS' FROM DUAL
    UNION SELECT 659, '1093', '201140', '200840', 'UG', '', '', 'Y', 'T', 'Y', 'BB' FROM DUALSo for the above data on ID '1962', I would like to select the record that has EXIST_NEWPROG = 'Y' and ignore the other rows for that ID. Note:EXIST_NEWPROG, VISITORS, NORMAL I added to sample data, these cols don't actually exist. Put in for easier display purpose to show what case statements are doing. The actual sql statement has many joins and where statements, but hopefully this simplification of the sql will be sufficient to derive a solution.
    WITH MULTIROWS AS
    SELECT 363 AS PERSON_UID, '1875' AS ID, '201140' AS ACADEMIC_PERIOD, '201040' AS ACADEMIC_PERIOD_ADMITTED, 'UG' AS STUDENT_LEVEL, '' AS EXIST_NEWPROG, 'Y' AS VISITORS, 'Y' AS NORMAL, 'V' AS STUDENT_POPULATION, 'Y' AS PRIMARY_PROGRAM_IND, 'LA' AS PROGRAM FROM DUAL
    UNION SELECT 852, '1962', '201130', '201040', 'GR', '', '', 'Y', 'C', 'Y', 'MS'  FROM DUAL
    UNION SELECT 852, '1962', '201140', '201140', 'GR', 'Y', '', '', 'G', 'N', 'MBA' FROM DUAL
    UNION SELECT 852, '1962', '201140', '201040', 'GR', '', '', 'Y', 'G', 'Y', 'MS' FROM DUAL
    UNION SELECT 659, '1093', '201140', '200840', 'UG', '', '', 'Y', 'T', 'Y', 'BB' FROM DUAL
    select *
    from multirows ac
    where  CASE WHEN ac.primary_program_ind = 'N'                                       --Existing Students who have a new program (Continuing Law and added Business)
                                   AND ac.academic_period_admitted = ac.academic_period
                                   AND ac.student_population <> 'V'
                                   AND ac.program is not null THEN 'Y'
                                WHEN ac.primary_program_ind = 'Y'                                        --Visitors (Each term considered new)
                                   AND ac.student_population = 'V'
                                   AND ac.academic_period_admitted is not null THEN 'Y'
                                WHEN ac.primary_program_ind = 'Y'                                        --Normal Cases
                                   AND ac.academic_period_admitted is not null THEN 'Y' --= ac.academic_period THEN 'Y'
                       END = 'Y'

    Hi,
    user1069723 wrote:
    Thanks Frank. I've been incorporating your solution and going over the data, (which is why it has taken so long to respond) and am getting closer, however the approach you provided excludes people who have a "RNum" of 2 or 3, but do not have a 1 at all. So people that only have a 2 and 3 OR only have a 2 or only have a 3 would not be captured, but if there is only one record, they would be missed.
    Here is another set of records of one person.
    SELECT 921 AS PERSON_UID, '8284' AS ID, '201130' AS ACADEMIC_PERIOD, '201030' AS ACADEMIC_PERIOD_ADMITTED, 'UG' AS STUDENT_LEVEL, '' AS EXIST_NEWPROG, 'Y' AS VISITORS, 'Y' AS NORMAL, 'V' AS STUDENT_POPULATION, 'Y' AS PRIMARY_PROGRAM_IND, 'LA' AS PROGRAM FROM DUAL
    UNION SELECT 921, '8284', '201140', '201040', 'UG', '', '', 'Y', 'F', 'Y', 'BB'  FROM DUAL
    Sorry, I can't reproduce the problem.
    If I add the two new rows of sample data that you posted today to the data you posted yesterday, then the query I posted yesterday produces:
    PERSON_UID ID   ACADEM ACADEM ST E V N S P PRO      R_NUM
           659 1093 201140 200840 UG     Y T Y BB           1
           363 1875 201140 201040 UG   Y Y V Y LA           1
           852 1962 201140 201140 GR Y     G N MBA          1
           921 8284 201130 201030 UG   Y Y V Y LA           1Io you get the correct output for the original ids?
    If I DELETE all the rows where id != 8284 I still get the same results for id=8284.
    'm using Oracle 11.1.0.6.0. What version are you running?
    Post your exact code, even iof you think you copied it from thsi site without any changes. Perhaps there was some subtle eidting mistake.
    I would like to select the record for Academic_Period = 201140 for this person. Is the problem that you're getting the wrong row for id=8284, or that you're not getting any output for id=8284?
    Why would you want to get the row with academic_period=201140? (Let's call this row A.) Why don't you want the other row for that person, the one with academic_period=201130? (Let's call this row B.) On both of those rows, primary_program_ind='Y' and academic_period_admitted is not NULL. The only significant difference between those two rows is that student_population='F' on row A, and it's 'V' on row B. Doesn't that mean that row B causes the CASE expression to return 3 ("Normal Case"), while row B makes it return 2 ("Visitor")? Doesn't that mean row B should be preferred to row A?
    Then again, perhaps this is just what you mean by saying that "term" is the main factor in deciding which row to select, and that the CASE expreesion ("New Program" before "Visitors", followed by "Normal Cases") is just a tie-breaker.
    Based on my understanding of the code you provided, this person is being excluded altogether because they do not have a record that evaluates to rnum = 1.ROW_NUMBER never returns a value of 2 or 3 unless it has already returned a value of 1. (At least that's how it's supposed to work, and I've never heard of any bugs concerning it.)
    This record is also complicated because it has two terms, Does "term" mean "academic_period" here?
    in all cases, we would want to select the highest term and then if there is still more than one qualifying record, base the "tie breaker" on the cases. Does this make sense or is my explanation still unclear?It's unclear.
    Maybe you need to add one more line at the beginning of the analytic ORDER BY clause (the 6th line below):
    WITH     got_r_num     AS
         SELECT     m.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                             ORDER BY       
                                             academic_period     DESC,          -- Added
                                             CASE
                                       WHEN  primary_program_ind      = 'N'     --Existing Students who have a new program (Continuing Law and added Business)
                                                       AND   academic_period_admitted      = academic_period
                                                       AND   student_population       != 'V'
                                                       AND   program                is not null
                                            THEN 1
                                                    WHEN  primary_program_ind      = 'Y'     --Visitors (Each term considered new)
                                                       AND   student_population      = 'V'
                                                       AND   academic_period_admitted is not null
                                            THEN 2
                                                    WHEN  primary_program_ind      = 'Y'     --Normal Cases
                                                   AND   academic_period_admitted is not null
                                            THEN 3
                                             END
                           )     AS r_num
         FROM     multirows     m
    --     WHERE     ...     -- If you need any filtering, this is where it goes
    SELECT     *     -- or list all columns except r_num
    FROM     got_r_num
    WHERE     r_num     = 1
    ;

  • Refresh page with data from the Next Record in the Table through a Button

    Scenario: Record of a table “prototype” is made up of 8 columns,
    key_col,
    text_col,
    label1_col, label2_col, label3_col,
    check1_col, check2_col, check3_col,
    I have created the following items on a page:
    a) A Display Only item that is populated through a SQL query
    “SELECT text_col from prototype where rownum=key_seq.NEXTVAL “.
    b) Hidden item for the database columns “label1_col, label2_col, label3_col”
    Source type for the hidden items is of type SQL query, Source expression is:
    Select label1_col from prototype where rownum=key_seq.NEXTVAL ;
    Select label2_col from prototype where rownum=key_seq.NEXTVAL ;
    Select label3_col from prototype where rownum=key_seq.NEXTVAL ;
    (key_seq is a sequence).
    c) Checkbox item for the database columns “ check1_col, check2_col,check3_col"
    d) The labels for the above checkbox items are &label1_col. , &label2_col. , &label3_col.
    I have created a Save button to save the state of the checkboxes; (STATIC:;1 )
    I want the page to be refreshed with the data from the next record (Fields text_col, label1_col, label2_col, label3_col) through a “ Next” Button.
    Can I please know how I can achieve this?
    Thanks in advance

    If you need the value that is entered in the textbox as the email body, then try this..
    <html>
    <HEAD>
    <title>WebForm1</title>
    <script language="javascript">
    function mailHTML() {
    var content=document.getElementById('textBox').value;
    location.href="mailto:?body="+encodeURI(content);
    </script>
    </head>
    <body>
    <form name="theform" id="theform">
    <div name="body1"/>
    <input type="text" value="Test" id="textBox"/>
    <input type="button" value="Send Email" onClick="mailHTML()"/>
    </div>
    </form>
    </body>
    </html>

  • Move to next record / wildcard search

    Hi
    Hope you can understand this explanation..
    I have searchable database for Holiday & Residential
    property here
    http://www.roomtobreathesl.com
    (search facility in the navigation menu)
    The results page for this search works fine for when you
    specify a certain
    area, certain amount of beds etc as it only shows a small
    amount of
    properties.
    However when you do a search for any area / any amount of
    rooms / any type,
    the query brings up over 40 results, so a move to next record
    is used. This
    is where the problem lies. You cannot move to next record as
    the 'Next
    record' link is looking for another wildcard search (see
    status bar).
    Any ideas how to remedy this?
    Thanks for any help
    Gary

    oops!
    Sorry sent you the previous version that's online.
    I also tried doing a search and replace and changing all
    'Request.Form' to
    'Request'
    Still didn't work.
    This is how it was when it wasn't working.
    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/YotShop6.asp" -->
    <%
    Dim rsResults__MMColParam
    rsResults__MMColParam = "1"
    If (Request("yscon") <> "") Then
    rsResults__MMColParam = Request("yscon")
    End If
    %>
    <%
    Dim rsResults__ysbed
    rsResults__ysbed = "1"
    If (Request("ysbed") <> "") Then
    rsResults__ysbed = Request("ysbed")
    End If
    %>
    <%
    Dim rsResults__MMColParam3
    rsResults__MMColParam3 = "xyz"
    If (Request("type") <> "") Then
    rsResults__MMColParam3 = Request("type")
    End If
    %>
    <%
    Dim rsResults
    Dim rsResults_numRows
    Set rsResults = Server.CreateObject("ADODB.Recordset")
    rsResults.ActiveConnection = MM_YotShop6_STRING
    rsResults.Source = "SELECT * FROM YotStock WHERE Area LIKE '"
    +
    Replace(rsResults__MMColParam, "'", "''") + "' AND bedrooms
    LIKE '" +
    Replace(rsResults__ysbed, "'", "''") + "' AND type LIKE '" +
    Replace(rsResults__MMColParam3, "'", "''") + "' ORDER BY
    price ASC"
    rsResults.CursorType = 0
    rsResults.CursorLocation = 2
    rsResults.LockType = 1
    rsResults.Open()
    rsResults_numRows = 0
    %>
    "Julian Roberts" <[email protected]> wrote in message
    news:euj4if$ici$[email protected]..
    >>> Use Request instead of Request.Form for runtime
    parameters.
    >
    > You haven't done it :)
    >
    > --
    > Jules
    >
    http://www.charon.co.uk/charoncart
    > Charon Cart 3
    > Shopping Cart Extension for Dreamweaver MX/MX 2004
    >
    >
    >
    >

  • How I can change this query to retun both records (max scores)

    This query does not retrieve records when I have two records for the same pidm (unique key) with the same score and different test date
    SORTEST_PIDM IS 'This field identifies the internal identification number of the student.'
       SELECT sortest_pidm,
                 CASE sortest_tesc_code WHEN 'S02' THEN 'S06' END CASE,
                 sortest_tsrc_code,
                 test_date,
                 sortest_test_score
                   FROM (SELECT a.*,
                         ROW_NUMBER ()
                         OVER (
                            PARTITION BY a.sortest_tesc_code, a.sortest_pidm
                            ORDER BY
                               a.sortest_test_score DESC,
                               a.sortest_test_date DESC)
                            rn
                    FROM sortest a
                   WHERE ---  a.sortest_pidm = 228709
                      -- sortest_pidm  =  107168
                      ---- sortest_pidm  =  30021 --
                     and    a.sortest_tesc_code = 'S02'
                         AND a.sortest_tsrc_code NOT IN ('SUPR'))
           WHERE rn = 1;like this one
    SORTEST_PIDM     SORTEST_TESC_CODE        SORTEST_TEST_DATE     SORTEST_TEST_SCORE     
    30037                      S02                        03/01/2010 00:00:00     630     
    30037                      S02                         05/01/2010 00:00:00     630      It retrieves data when the scores are different
    like this one
    SORTEST_PIDM     SORTEST_TESC_CODE        SORTEST_TEST_DATE     SORTEST_TEST_SCORE
    107168                      S02                                        06/01/2010 00:00:00         690
    107168                      S02                                        10/01/2010 00:00:00     800I need to be able to return the maximun test scrore in both cases...
    here is some code to create a test table and insert the codes, I took out the sortest the table is already in the DB, I called the test table test...
        CREATE TABLE TEST
       TEST_PIDM             NUMBER(8)            NOT NULL,
       TESC_CODE        VARCHAR2(4 CHAR)     NOT NULL,
       TEST_DATE        DATE                 NOT NULL,
       TEST_SCORE       VARCHAR2(5 CHAR)     NOT NULL
       insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select    30037,'S02',to_date('03/01/2010','mm/dd/yyyy'),'630' from dual ;
        insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select    30037,'S02',to_date('05/01/2010','mm/dd/yyyy'),'630' from dual ;
       insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select      107168 ,'S02',to_date('06/01/2010','mm/dd/yyyy'),'690' from dual ;
        insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select      107168 ,'S02',to_date('10/01/2010','mm/dd/yyyy'),'800' from dual;
      

    Hi,
    893973 wrote:
    This query does not retrieve records when I have two records for the same pidm (unique key) with the same score and different test date
    SORTEST_PIDM IS 'This field identifies the internal identification number of the student.'
    SELECT sortest_pidm,
    CASE sortest_tesc_code WHEN 'S02' THEN 'S06' END CASE,
    sortest_tsrc_code,
    test_date,
    sortest_test_score
    FROM (SELECT a.*,
    ROW_NUMBER ()
    OVER (
    PARTITION BY a.sortest_tesc_code, a.sortest_pidm
    ORDER BY
    a.sortest_test_score DESC,
    a.sortest_test_date DESC)
    rn
    FROM sortest a
    WHERE ---  a.sortest_pidm = 228709
    -- sortest_pidm  =  107168
    ---- sortest_pidm  =  30021 --
    and    a.sortest_tesc_code = 'S02'
    AND a.sortest_tsrc_code NOT IN ('SUPR'))
    WHERE rn = 1;like this one
    SORTEST_PIDM     SORTEST_TESC_CODE        SORTEST_TEST_DATE     SORTEST_TEST_SCORE     
    30037                      S02                        03/01/2010 00:00:00     630     
    30037                      S02                         05/01/2010 00:00:00     630      It retrieves data when the scores are different
    like this one
    SORTEST_PIDM     SORTEST_TESC_CODE        SORTEST_TEST_DATE     SORTEST_TEST_SCORE
    107168                      S02                                        06/01/2010 00:00:00         690
    107168                      S02                                        10/01/2010 00:00:00     800I need to be able to return the maximun test scrore in both cases...
    here is some code to create a test table and insert the codes, I took out the sortest the table is already in the DB, I called the test table test... It looks like you renamed all the columns, too, making the query above useless. There's no danger in using the same column names in two or more tables, even in the same schema.
    CREATE TABLE TEST
    TEST_PIDM             NUMBER(8)            NOT NULL,
    TESC_CODE        VARCHAR2(4 CHAR)     NOT NULL,
    TEST_DATE        DATE                 NOT NULL,
    TEST_SCORE       VARCHAR2(5 CHAR)     NOT NULL
    insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select    30037,'S02',to_date('03/01/2010','mm/dd/yyyy'),'630' from dual ;
    insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select    30037,'S02',to_date('05/01/2010','mm/dd/yyyy'),'630' from dual ;
    insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select      107168 ,'S02',to_date('06/01/2010','mm/dd/yyyy'),'690' from dual ;
    insert into test (TEST_PIDM,TESC_CODE,TEST_DATE,TEST_SCORE) select      107168 ,'S02',to_date('10/01/2010','mm/dd/yyyy'),'800' from dual; If you want to pick the highest scores, regardless of test date, then don't include test_date in the analytic ORDER BY clause.
    If you want to pick all the rows with the highest score in case of a tie, then use RANK instead of ROW_NUMBER.

  • Facing problem in implementing the analytical query in OWB

    Hi All,
    I was trying analytical function for my Customer Dimension but am not able to implement the same in my OWB.I have 2 tables who have duplicates customers which cannot be figured out by Customer id as customer id is not unique.So, i have to filter out the information on the basis of First Name, middle name, last name & DOB. Since, each customer has multiple address records( for Permanent, Correspondence, Unknown ).
    I want 1 record for all the three address types.
    Can i do thru the following query???
    If yes, how will i implment the same in OWB.
    SELECT PRENOM, MIDDLE_NAME, NOM, DEBUT, SEXE, OCCUPATION, FAMILY_STATUS,
         EDUC_QUALIFICATION, CUSTOMER_NATIONALITY, SIGLE, ANNUAL_INCOME,
         FATHER_HUSBAND_NAME,TYPE_ADDRESS, ADDRESS1, ADDRESS2, ADDRESS3,
         TOWN, REGION, POSTCODE,ADDRESS_EFFECT_DATE
    FROM
    (SELECT C1.PRENOM, C1.MIDDLE_NAME, C1.NOM, C1.DEBUT, C1.SEXE, C1.OCCUPATION, C1.FAMILY_STATUS,
         C1.EDUC_QUALIFICATION, C1.CUSTOMER_NATIONALITY, C1.SIGLE, C1.ANNUAL_INCOME,
         C1.FATHER_HUSBAND_NAME,C1.TYPE_ADDRESS, C1.ADDRESS1, C1.ADDRESS2, C1.ADDRESS3,
         C1.TOWN, C1.REGION, C1.POSTCODE,C1.ADDRESS_EFFECT_DATE,
    ROW_NUMBER() OVER (PARTITION BY C1.PRENOM, C1.MIDDLE_NAME, C1.NOM, C1.DEBUT,C1.TYPE_ADDRESS
    ORDER BY C1.ADDRESS_EFFECT_DATE DESC)M
    FROM CUST_1 C1
    UNION ALL
    SELECT C1.PR_FIRST_NM, C1.PR_MIDDLE_NM, C1.PR_LAST_NM, C1.PR_DOB, C1.PR_GENDER, C1.PR_OCCUPATION, C1.PR_MARITAL_STATUS,
    C1.PR_EDUCATION_QUAL, C1.PR_NATIONALITY, C1.PR_TITLE, C1.GP_ANNUAL_INC, C1.PR_FATHER_NM,
    C1.AD_TYPE, C1.AD_ADDR1, C1.AD_ADDR2, C1.AD_ADDR3, C1.TOWN, C1.REGION, C1.AD_PIN_CD,C1.REC_UPDT_DT,
    ROW_NUMBER() OVER (PARTITION BY C1.PR_FIRST_NM, C1.PR_MIDDLE_NM, C1.PR_LAST_NM, C1.PR_DOB,C1.AD_TYPE
    ORDER BY C1.REC_UPDT_DT DESC )M
    FROM CUST_2 C1)
    WHERE M = 1
    Please help me out as right now, am using aggregators which are taking lot of time. Loading type on my Customer Dimension table is- Insert/Update
    Thanks in advance
    -Nikita.

    Hello Nikita,
    From your first post I understand that you would like to merge 3 similar (but not complete identical) records into 1 record. If this is the case, then have you thought about using the match-merge operator in OWB?
    With the match-merge operator you can tell the mapping which records are similar by selecting "first_nm", "middle_nm", "last_nm" in the Match-Bin of the operator.
    Then you define how attributes should be merged.
    This way you do not need to aggregate your source data set. Just select all records from both source tables. Put those in the Set-Operator "UNION ALL" and this will be you input for the match-merge operator.
    Regards,
    Ilona

Maybe you are looking for

  • I installed the update and now my itunes won't open - can anyone help?

    I had to update as it wouldn't recognise my iphone anymore, although it opened fine prior to the upgrade.

  • No data appears in s/scf/snc

    Hi, after updating the SNC 7.0 from support package level 0 to support package level 8 I cannot do anything in any of the WEB Uis for SAP SNC. If I press on SNC link, it opens the browser and appears a message saying User Not Found. Before I updated

  • Photoshop workflow question

    I read somewhere that using <ALT> + Click you can use to load alpha channels could someone verify what is the correct method ? And clipping only applies to the background layer when you apply a change to the canvas I was told but I'm unclear about th

  • Mutually convertible Unicode

    When I change the next code (Adaptation unicode): IF t004-sakln > 0. *{   REPLACE        &$&$&$&$                                          1 *      DESCRIBE FIELD ska1-bilkt LENGTH sy-fdpos.       DESCRIBE FIELD ska1-bilkt LENGTH sy-fdpos IN CHARACTE

  • Iphone 5 will not sync with itunes.

    I have tried every suggestion posted to date, with the exception of purchasing a new cable.       all software is up to date, with the exception of my system software (10.6.8)      powered off and re-started both the mac and the iphone      unplugged