Using row numbers in sql

I want to do a select query based on row numbers and was wondering if its possible.
for example,
select * from TABLE where rownumber = x;
Thanks.

There is one special case where
SELECT * FROM table WHERE rownum = x
will work, x = 1. Note, the proper psuedo column name is ROWNUM.
You can do something like:
SELECT *
FROM (SELECT *,rownum rn
      FROM table)
WHERE rn = xfor any value of rownum up to the number of rows in table.
TTFN
John

Similar Messages

  • Serial numbers via sql query

    Hi,
    I'm having trouble getting the correct serial numbers via SQL.
    From PHP I run the following query to get the Delivery Notes:
    select ODLN.DocEntry,ODLN.CardCode,ODLN.CardName,ODLN.DocDueDate,ODLN.DocDate,ODLN.NumAtCard,NNM1.SeriesName,ODLN.DocNum,ODLN.SlpCode,ODLN.CANCELED,ODLN.DocStatus,DLN1.ItemCode,DLN1.Dscription,DLN1.Quantity,DLN1.ShipDate,DLN1.LineStatus,ODLN.NumAtCard,ODLN.U_CodSit,ODLN.DocTotal,ODLN.DocCur,ODLN.CreateDate,ODLN.TrackNo,DLN1.SerialNum from ODLN INNER JOIN NNM1 ON (ODLN.Series = NNM1.Series) INNER JOIN OCRD ON (ODLN.CardCode = OCRD.CardCode AND OCRD.CardCode = '".$_POST["sapcode"]."' AND OCRD.Password = '".$_POST["sappwd"]."') INNER JOIN DLN1 ON ODLN.DocEntry = DLN1.DocEntry ORDER BY ODLN.CreateDate DESC,ODLN.DocEntry ASC
    While I loop through the results I then try to grab the serial numbers. I tried this:
    SELECT OSRI.IntrSerial FROM OSRI INNER JOIN SRI1 ON ( (SRI1.SysSerial = OSRI.SysSerial) AND (SRI1.BaseNum = ".$row['DocNum'].") ) INNER JOIN DLN1 ON (DLN1.DocEntry = SRI1.BaseEntry) WHERE ( (DLN1.DocEntry = ".$row['DocEntry'].") AND (DLN1.ItemCode = OSRI.ItemCode) AND (DLN1.ItemCode = '".$row['ItemCode']."') ) ORDER BY OSRI.IntrSerial
    but it gives me incoherent results compared to what appears in the SAP b1 client. For ex., some serial numbers are fine but in other cases I get more serial numbers than accounted for (article quantity = 1 but get 2 serial numbers; in SAP B1 client only one of the two serial numbers appears, as expected).
    So I then modified the query and added a check for the CardCode:
    SELECT OSRI.IntrSerial FROM OSRI INNER JOIN SRI1 ON ( (SRI1.SysSerial = OSRI.SysSerial) AND (SRI1.BaseNum = ".$row['DocNum'].") AND (SRI1.CardCode = '".$_POST["sapcode"]."') ) INNER JOIN DLN1 ON (DLN1.DocEntry = SRI1.BaseEntry) WHERE ( (OSRI.CardCode = '".$_POST["sapcode"]."') AND (DLN1.DocEntry = ".$row['DocEntry'].") AND (DLN1.ItemCode = OSRI.ItemCode) AND (DLN1.ItemCode = '".$row['ItemCode']."') ) ORDER BY OSRI.IntrSerial
    This query is slightly better in the sense that at least I don't get serial numbers that are not supposed to be there (eg. if quantity=1 I will not get 2 serial numbers as in the previous query). However, in some cases it works as expected and in other delivery notes it doesn't because it simply doesn't list the serial numbers (which where found in the first query).
    It might be because the CardCode field isn't always thoroughly set?
    If so, is it just a "user problem" so I should tell my company to review the way they fill SAP data?
    Or am I doing the wrong query?
    (The SDK doc regarding OSRI is confusing as it doesn't even point to SRI1 and I don't fully understand the relationships)
    Regards,
    Vieri

    Vieri,
    you can catch (using MS SQL Profiler) the query which is executed by SBO once you click on serial nambers report from Delivery Note form.
    this is one of the ways to get a solution quickly.

  • Calculating values from row to row with pure sql?

    Hello,
    I'm searching for a way to calculate values from row to row with pure sql. I need to create an amortisation table. How should it work:
    Known values at start: (they can be derived with an ordinary sql-statement)
    - redemption amount RA
    - number of payment terms NT
    - annuity P (is constant in every month)
    - interest rate IR
    What has to be calculated:
    First row:
    RA1 = RA - P
    Z1 = (RA1 * (IR/100/12))
    T1 = P - Z1
    2nd row
    RA2 = RA1 - T1
    Z2 = (RA2 * (IR/100/12))
    T2 = P - Z2
    and so on until NT has reached.
    It should look like
    NT
    P
    Tn
    Zn
    RAn
    1
    372,17
    262,9
    109,27
    22224,83
    2
    372,17
    264,19
    107,98
    21961,93
    3
    372,17
    265,49
    106,68
    21697,74
    4
    372,17
    266,8
    105,38
    21432,25
    5
    372,17
    268,11
    104,06
    21165,45
    6
    372,17
    269,43
    102,75
    20897,34
    7
    372,17
    270,75
    101,42
    20627,91
    8
    372,17
    272,09
    100,09
    20357,16
    9
    372,17
    273,42
    98,75
    20085,07
    10
    372,17
    274,77
    97,41
    19811,65
    11
    372,17
    276,12
    96,06
    19536,88
    12
    372,17
    277,48
    94,7
    19260,76
    13
    372,17
    278,84
    93,33
    18983,28
    14
    372,17
    280,21
    91,96
    18704,44
    15
    372,17
    281,59
    90,59
    18424,23
    16
    372,17
    282,97
    89,2
    18142,64
    17
    372,17
    284,36
    87,81
    17859,67
    18
    372,17
    285,76
    86,41
    17575,31
    19
    372,17
    287,17
    85,01
    17289,55
    20
    372,17
    288,58
    83,59
    17002,38
    21
    372,17
    290
    82,18
    16713,8
    22
    372,17
    291,42
    80,75
    16423,8
    23
    372,17
    292,86
    79,32
    16132,38
    24
    372,17
    294,3
    77,88
    15839,52
    25
    372,17
    295,74
    76,43
    15545,22
    26
    372,17
    297,2
    74,98
    15249,48
    27
    372,17
    298,66
    73,52
    14952,28
    28
    372,17
    300,13
    72,05
    14653,62
    29
    372,17
    301,6
    70,57
    14353,49
    30
    372,17
    303,09
    69,09
    14051,89
    31
    372,17
    304,58
    67,6
    13748,8
    32
    372,17
    306,07
    66,1
    13444,22
    33
    372,17
    307,58
    64,6
    13138,15
    34
    372,17
    309,09
    63,08
    12830,57
    35
    372,17
    310,61
    61,56
    12521,48
    36
    372,17
    312,14
    60,04
    12210,87
    37
    372,17
    313,67
    58,5
    11898,73
    38
    372,17
    315,21
    56,96
    11585,06
    39
    372,17
    316,76
    55,41
    11269,85
    40
    372,17
    318,32
    53,85
    10953,09
    41
    372,17
    319,89
    52,29
    10634,77
    42
    372,17
    321,46
    50,71
    10314,88
    43
    372,17
    323,04
    49,13
    9993,42
    44
    372,17
    324,63
    47,55
    9670,38
    45
    372,17
    326,22
    45,95
    9345,75
    46
    372,17
    327,83
    44,35
    9019,53
    47
    372,17
    329,44
    42,73
    8691,7
    48
    372,17
    331,06
    41,11
    8362,26
    I would appreciate every help and idea to solve the problem solely with sql.
    Thanks and regards
    Carsten

    It's using Model Clause and / or Recursive With (sometimes maybe both)
    Regards
    Etbin
    with
    rec_proc(nt,i,ra,p,ir,z,t) as
    (select nt,i,ra - p,p,ir,round((ra - p) * 0.01 * ir / 12,2),p - round((ra - p) * 0.01 * ir / 12,2)
       from (select 48 nt,22597 ra,372.17 p,5.9 ir,0 z,0 t,1 i
               from dual
    union all
    select nt,i + 1,ra - t,p,ir,round((ra - t) * 0.01 * ir / 12,2),p - round((ra - t) * 0.01 * ir / 12,2)
       from rec_proc
      where i < nt
    select * from rec_proc
    try to adjust initial values and rounding please
    NT
    I
    RA
    P
    IR
    Z
    T
    48
    1
    22224.83
    372.17
    5.9
    109.27
    262.9
    48
    2
    21961.93
    372.17
    5.9
    107.98
    264.19
    48
    3
    21697.74
    372.17
    5.9
    106.68
    265.49
    48
    4
    21432.25
    372.17
    5.9
    105.38
    266.79
    48
    5
    21165.46
    372.17
    5.9
    104.06
    268.11
    48
    6
    20897.35
    372.17
    5.9
    102.75
    269.42
    48
    7
    20627.93
    372.17
    5.9
    101.42
    270.75
    48
    8
    20357.18
    372.17
    5.9
    100.09
    272.08
    48
    9
    20085.1
    372.17
    5.9
    98.75
    273.42
    48
    10
    19811.68
    372.17
    5.9
    97.41
    274.76
    48
    11
    19536.92
    372.17
    5.9
    96.06
    276.11
    48
    12
    19260.81
    372.17
    5.9
    94.7
    277.47
    48
    13
    18983.34
    372.17
    5.9
    93.33
    278.84
    48
    14
    18704.5
    372.17
    5.9
    91.96
    280.21
    48
    15
    18424.29
    372.17
    5.9
    90.59
    281.58
    48
    16
    18142.71
    372.17
    5.9
    89.2
    282.97
    48
    17
    17859.74
    372.17
    5.9
    87.81
    284.36
    48
    18
    17575.38
    372.17
    5.9
    86.41
    285.76
    48
    19
    17289.62
    372.17
    5.9
    85.01
    287.16
    48
    20
    17002.46
    372.17
    5.9
    83.6
    288.57
    48
    21
    16713.89
    372.17
    5.9
    82.18
    289.99
    48
    22
    16423.9
    372.17
    5.9
    80.75
    291.42
    48
    23
    16132.48
    372.17
    5.9
    79.32
    292.85
    48
    24
    15839.63
    372.17
    5.9
    77.88
    294.29
    48
    25
    15545.34
    372.17
    5.9
    76.43
    295.74
    48
    26
    15249.6
    372.17
    5.9
    74.98
    297.19
    48
    27
    14952.41
    372.17
    5.9
    73.52
    298.65
    48
    28
    14653.76
    372.17
    5.9
    72.05
    300.12
    48
    29
    14353.64
    372.17
    5.9
    70.57
    301.6
    48
    30

  • How to print a report without row numbers or grid lines?

    Is there a way to print a Discoverer report without row numbers or grid lines?
    Thank you.
    Blake

    Hi Blake
    You're not doing anything wrong.
    The settings made when you use Tools | Options | Sheet are global settings that are only applied to new workbooks and worksheets going forwards. These have no impact on existing worksheets or even the one you currently have open. This is because Discoverer does not know whether your original worksheets were setup in a certain way deliberately as opposed to inheriting the global settings as they were at that time. What this also means, reading between the lines, is that these settings must then be stored within the worksheet itself, and this is exactly what happens.
    Thus, to edit an existing worksheet's settings you need to open the worksheet, right-click in the sheet and from the popup select either Format Table or Format Crosstab depending upon the type of worksheet you are working with. After making any necessary changes you will need to save or re-save the workbook in order for those settings to be remembered for the next time.
    Best wishes
    Michael

  • How to get multiple records using fn-bea:execute-sql()

    Hi,
    I created Proxy service(ALSB3.0) to get records from DB table. I have used Xquery function(fn-bea:execute-sql()). Using simple SQL query I got single record, but my table having multiple records. Please suggest how to get multiple records using fn-bea:execute-sql() and how to assign them in ALSB variable.
    Regards,
    Nagaraju
    Edited by: user10373980 on Sep 29, 2008 6:11 AM

    Hi,
    Am facing the same issue stated above that I couldnt get all the records in the table that am querying in the Proxyservice.
    For example:
    fn-bea:execute-sql('EsbDataSource', 'student', 'select Name from StudentList' ) is the query that am using to fetch the records from the table called StudentList which contains more than one records like
    Id Name
    01 XXX
    02 YYY
    03 ZZZ
    I tried to assign the result of the above query in a variable and while trying to log the variable, I can see the below
    <student>
    <Name>XXX</Name>
    </student>
    I want to have all the records from my table in xml format but it's not coming up. I get the value only from the first row of my table.
    Please suggest.
    regards,
    Venkat

  • Is there a way to have a Numbers spreadsheet show the row numbers on ipad?

    I am have a spreadsheet I am using for keeping count of the current people registered for an event.
    If there a way to have one of the columns automatically show the row numbers so I can easily see the amount of people confirmed for the event without having to manually count them? Also, I will be adding and deleting lines and need Numbers to automatically show the row numbers without me having to change it.
    Thanks,
    Mike

    I found it out:
    inserted a new column A
    a --
    In A1 type 1
    in A2 type 2
    select the pair A1:A2
    drag the circular handle from the bottom right of A2 thru the very bottom of the column.
    b --
    in A1 type =ROW()
    select the cell A1
    drag the circular handle from the bottom right of A1 thru the very bottom of the column.

  • Cannot use Row Exchange Rate in the Draw Document Wizard

    Hi Experts,
    I am having problems while trying to post an AP Invoice which is copied from a Goods Receipt PO. I made two transactions in GRPO:
    12/28/2011 - I used the BP Currency which is USD and the exchange rate of PHP 45. Doc No.1198
    12/29/2011 -  I used the BP Currency which is USD and the exchange rate of PHP 47. Doc No. 1199
    While adding the AP Invoice on 12/30/2011,  I have an exchange rate of PHP 46.
    When trying to add the AP Invoice, I used Copy From Goods Receipt PO and I higlighted the two doc numbers 1198 and 1199. In the Draw Document Wizard Row Ex. Rate Prices I have selected the Use Row Exchange Rate from Base Document.  However a system message appears which says Base Document Exchange Rate cannot be used, the rows will be updated using the target document exchange rate.
    My presumption is that when I choose the Row exchange rate from base document, SAP will automatically copy the row exchange rate used in the documents so for the transactions in 12/28, the rate of PHP 45 shall be used and same goes for the 12/29 which is PHP 47.
    How should I go about this? Am I missing a step here? By the way, I am using SAP B1 8.82 PL01.
    Thanks in advance for your help.
    Best Regards,
    Michelle Pereyras
    ABM Global Solutions

    Hi Rahul,
    You said 'It is not at all concerned with Exchange rate during GRPO...' If that is the case how does the Use Row Exchange Rate from Base Document in the draw document wizard work? Does this mean 1 GRPO : 1 AP Invoice so I can use the base document rate?
    How should I go about with transactions like these? That is adding an AP Invoice from multiple GRPO's having different exchange rates. What I am trying to capture here is that in the AP Invoice, base document rates should be used in the row item level and not the current rate when adding the invoice.  
    Thanks,
    Michelle

  • How to compare two rows in PL/SQL?

    Hi All,
    How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?
    Any feedback would be highly appreciated.

    PhoenixBai wrote:
    Hi All,
    How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?What "rows" are you referring to?
    If you're talking of rows within a PL/SQL associative array there are techniques as described in the documentation... e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type v1 is table of number;
      3    r1 v1 := v1(1,2,4);
      4    r2 v1 := v1(1,2,3);
      5  begin
      6    if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
      7      dbms_output.put_line('Same');
      8    else
      9      dbms_output.put_line('Different');
    10    end if;
    11* end;
    SQL> /
    Different
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type v1 is table of number;
      3    r1 v1 := v1(1,2,3);
      4    r2 v1 := v1(1,2,3);
      5  begin
      6    if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
      7      dbms_output.put_line('Same');
      8    else
      9      dbms_output.put_line('Different');
    10    end if;
    11* end;
    SQL> /
    Same
    PL/SQL procedure successfully completed.
    SQL>If you're talking about rows on a table then you can use the MINUS set operator to find the rows that differ between two sets of data...
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    14 rows selected.
    SQL> select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    7 rows selected.
    SQL> select * from emp
      2  minus
      3  select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
    7 rows selected.If you actually need to know what columns data is different on "non-matching" rows (based on your primary key) then you'll have to compare column by column.

  • Using UPDATE in complex SQL

    I wonder if anyone can help with an update..
    Image 2 tables: packagetable and parttable
    packagetable has component to part relationships, eg:
    Package Part
    PACK1 PART1
    PACK1 PART2
    PACK2 PART6
    PACK2 PART7
    PACK2 PART9
    PACK3 PART3
    PACK3 PART7
    parttable has parts and their price
    Part Price
    PART1 10
    PART2 8
    PART3 15
    PART6 1
    PART7 5
    PART9 10
    but packages are also stored here as parts and have a price (total of components)
    PACK1 18 (10 + 8)
    PACK2 16 (1 + 5 + 10)
    PACK3 20 (15 + 5)
    The actual tables are more complex and include a site, a discount, a qty per package, etc but you get the gist.
    I need to update package parts so that they equate to the total of their parts because some package parts have the wrong price.
    So I need to say
    PACK1 = price of PART1 + price of PART2
    PACK2 = price of PART6 + price of PART7 + price of PART9
    PACK3 = price of PART3 + price of PART7
    The actual SQL to obtain the resultant price is:
    select
    spp1.parent_part packpart,
    (select sp2.list_price from ifsapp.sales_part sp2 where sp2.catalog_no = spp1.parent_part) Current_price,
    sum((sp1.list_price - (round(sp1.list_price*(spp1.discount_perc/100),2))) * spp1.qty_per_assembly) Proposed_price
    from
    ifsapp.sales_part_package spp1,
    ifsapp.sales_part sp1
    where
    spp1.catalog_no=sp1.catalog_no
    and
    spp1.contract=sp1.contract
    and
    spp1.contract='OIAMN'
    having
    sum((sp1.list_price - (round(sp1.list_price*(spp1.discount_perc/100),2))) * spp1.qty_per_assembly)<9999999
    group by
    spp1.parent_part
    This results in this case are:
    Package Part     Current          Proposed
    123          0.00          4911.90
    124          0.00          23450.00
    126          0.00          23450.00
    128          0.00          23950.00
    133          0.00          26975.00
    134          1200.00          1249.86
    140          0.00          9995.00
    144          0.00          9995.00
    145          0.00          8995.00
    150          9021.00          9994.97
    151          0.00          9994.97
    152          0.00          8994.97
    155          0.00          17895.00
    168          0.00          17095.00
    Clealry the only two values I really need are Package Part and Proposed value... but how can I update the package part prices using a single SQL statement?

    If I interpret your question right,
    merge works for you in 9i and 10G:
    SQL> select * from emps;
    ENAME          DEPTNO       SSAL
    SMITH              20
    ALLEN              30
    WARD               30
    JONES              20
    MARTIN             30
    BLAKE              30
    CLARK              10
    SCOTT              20
    KING               10
    TURNER             30
    ADAMS              20
    JAMES              30
    FORD               20
    MILLER             10
    14 rows selected.
    SQL> select * from sals;
    ENAME             SAL
    SMITH            1000
    ALLEN            1800
    WARD             1450
    JONES            2975
    MARTIN           1250
    BLAKE            2850
    CLARK            2450
    SCOTT            3000
    KING             5000
    TURNER           1500
    ADAMS            1100
    JAMES            1120
    FORD             3000
    MILLER           1300
    14 rows selected.
    SQL> /* In 9i */
    SQL> merge into emps
      2  using (
      3  select e.deptno,sum(s.sal) sm from emps e, sals s
      4  where e.ename = s.ename
      5  group by e.deptno
      6  ) src
      7  on (src.deptno = emps.deptno)
      8  when matched then
      9   update set emps.ssal = src.sm
    10  when not matched then
    11   insert (emps.deptno) values(0)
    12  /
    14 rows merged.
    SQL>/* In 10G */
    SQL> merge into emps
      2  using (
      3  select e.deptno,sum(s.sal) sm from emps e, sals s
      4  where e.ename = s.ename
      5  group by e.deptno
      6  ) src
      7  on (src.deptno = emps.deptno)
      8  when matched then
      9   update set emps.ssal = src.sm
    10  /
    14 rows merged.
    SQL> select * from emps order by deptno;
    ENAME          DEPTNO       SSAL
    CLARK              10       8750
    KING               10       8750
    MILLER             10       8750
    SMITH              20      11075
    ADAMS              20      11075
    FORD               20      11075
    SCOTT              20      11075
    JONES              20      11075
    ALLEN              30       9970
    BLAKE              30       9970
    MARTIN             30       9970
    JAMES              30       9970
    TURNER             30       9970
    WARD               30       9970
    14 rows selected.But it could be better if you changed the structure you were using - you could
    pick out package names and price summary in the separate table -
    now you packagetable looks as the unnormalized structure which is overloaded
    by data.
    Rgds.

  • Using row-wise multi-value GROUP system session variable in report filter

    The title says it all except I am using 10g OBIEE.
    What I want to do is filter on the dynamic system session variable GROUP created in a row-wise initialization block.
    The GROUP vriable is being set up correctly and it shows the user dynamically put into the correct groups in Answers.
    (Using the admin tool and looking at the user session, only the initial authentication block variables show up.)
    But if I want to filter using the value of GROUP it doesn't work.
    The obvious way is to choose the filter icon, then choose Add -> Variable -> Session, enter GROUP, and then display results.
    It comes back with no rows.
    Any idea how to do this? I've tried lots of things but none of them work either producing no rows or an error.
    This is the kind of Answers SQL this report is resulting in, which makes sense to me, but produces no rows.
    SELECT "Package Virtual Group (Dim)"."Package Virtual Group" saw_0, "Contact (Fact)"."Contacts All Count" saw_1 FROM "Case/Transaction/ABC" WHERE "Package Virtual Group (Dim)"."Package Virtual Group" = VALUEOF(NQ_SESSION."GROUP") ORDER BY saw_0

    866038 wrote:
    Errors come from trying things that don't work.
    For example, instead of =, using IN VALUEOF(NQ_SESSION.GROUP) or @{session.GROUP} or lots of other things.
    The question is this:
    how can I filter a column in Answers using the GROUP session variable which had been initialized in a row-wise initialization block?
    I can find no way to do it. Mostly it returns no rows.Hi,
    we had a similar requirement, where we have an external name that has project number values. We used row wise initialization to capture all the projects that a user belongs to. Then, we applied the filters at the RPD level, instead of doing it at the report level. From you requirement I see that you are trying to filter the groups based on user login. When a user logs in, he will see the information about the groups that he only belongs to. Correct me if I am wrong here.
    Assuming I am right about your requirement, providing the filter that you need apply in RPD.
    On all the fact tables are joined to the Package Virtual Group dimension, apply the below filter.
    case when 1=1 then (Dim)"."Package Virtual Group" END = VALUEOF(NQ_SESSION."GROUP");
    The reason for use of case statement here is, it converts the logical sql to IN Clause, helping us acheive the exact query that we would want.
    Please Award points if this helps.
    Thanks,
    -Amith.

  • Auto create request by reading a row in MS SQL table?

    Auto create request by reading a row in MS SQL table?
    If all required data for a particular request type were included in a row of a MS SQL db table (staging table), could a request be created using a db adaptor?  Or is web services the only option to auto create a request?

    By definition, a DB adapter is part of ServiceLink and ServiceLink handles task-level integration, ie, it can externalize a task that's in a request that already exists. Web Services is the only option to create a new request.

  • Excel 2010 Row numbers disappearing

    Question: Bit of an odd one here.
    Running Excel 2010 on a WinXP Sp3 box. Issue is only affecting one user and one of his spreadsheets. Sporatically, the actual numbers within the row identifier boxes vanishes, along with the data in the affected rows. The rows are still there, and the rows
    above and below are still numbered in the same sequencial order as if the affected rows were still numbered. If we do not notice this before saving spreadsheet, data is lost. If we unhide all cells, the numbers come back, as does the data. The odd thing is,
    as I said, the rows are NOT actually hidden, only the row identifier numbers and the data are gone.
    Please help! Critical order tracking sheet.

    Using  Windows 7 Professional ver 6.1 (Build 7601 : Service Pack 1) and Excel version 14.0.6112.5000 (32 bit)
    A large spreadsheet some 8MB and formatted as an xls file.
    I experienced a similar problem  with some  row  numbers and data missing together with some rows being expanded to a height of  550 pixels.
    Highlighting the whole row and automatically resetting the height (double clicking bottom edge ) sometimes resets the height, row numbers and data.
    Strangely highlighting the row and clicking the bold button also resets the the height, row numbers and data.
    Unfortunately these remedy’s do not persist after saving the file and reopening it.
    If I resave the "corrupted" xls version  as a Macro-Enabled Worksheet .xlsm file all of the issues above disappear.
    I hope this helps some one

  • How can i get the failed row numbers in batch insertion?

    Afeter execution of batch insert operation into a table, i use OCIAttrGet() to get the error number of insertion, as expected, it returns the correct number. however, when i use OCIParamGet() to get an error handle and then to get the exact failed row numbers , OCIParamGet() returns -2 , means "INVALID_HANDLE". can anyboy tell me why ? how can i get the exact failed rows?
    the snapshot of my code :
    int errNum = 0;
    int nRet = 0;
    nRet = OCIAttrGet((dvoid *)m_pIIOdbc->m_pStmtAll,OCI_HTYPE_STMT,&errNum,
              0,OCI_ATTR_NUM_DML_ERRORS, m_pIIOdbc->m_pErrHandle);
    if (errNum)
         OCIError* pErrHndl;
         int* pRow_off = new int[errNum];
         for (int i = 0; i < errNum; i++)
         nRet = OCIParamGet(m_pIIOdbc->m_pErrHandle,
    OCI_HTYPE_ERROR, m_pIIOdbc->m_pErrHandle, &pErrHndl, i + 1);
         nRet = OCIAttrGet (pErrHndl, OCI_HTYPE_ERROR, &pRow_off, 0,
         OCI_ATTR_DML_ROW_OFFSET, m_pIIOdbc->m_pErrHandle);
              delete []pRow_off;

    now the code is :
    OCIEnv      *m_pEnvHandle;                    
    OCIError      *m_pErrHandle;                         
    OCIError     *m_pErrHandle2;                    
    OCIServer *m_pSrvHandle;                         
    OCISvcCtx *m_pSvcHandle;                         
    OCIStmt *m_pStmtExec;
    OCIStmt *m_pStmtAll;
    OCIError** m_pErrorHndl;     
    int* m_pRowOff; //the array that will contain the failed row numbers
    int     m_nArrayLength; //length of array in once batch operation
    int m_nErrNum; //error number
    int m_nSucCount; //successful record number
    //initialization
    //m_nArrayLength is a parameter passed in, so i can not tell the exact length of the array, dynamic space allocation is needed
    m_pErrorHndl = new OCIError*[m_nArrayLength];
    m_pRowOff = new int[m_nArrayLength];
    //execution
    OCIStmtExecute(
              m_pSvcHandle,
              m_pStmtAll,
              m_pErrHandle,
              (ub4)m_nArrayLength,
              (ub4)0, (OCISnapshot *)NULL, (OCISnapshot *)NULL,
              OCI_BATCH_ERRORS
    //get successful records number
    m_nSucCount = 0;
    OCIAttrGet((dvoid *)m_pStmtAll,OCI_HTYPE_STMT,&m_nSucCount,
              0,OCI_ATTR_ROW_COUNT, m_pErrHandle);
    //get error numbers
    m_nErrNum = 0;
    OCIAttrGet((dvoid *)m_pStmtAll,OCI_HTYPE_STMT,&m_nErrNum,
              0,OCI_ATTR_NUM_DML_ERRORS, m_pErrHandle2);
    //get failed row numbers into the array
    if (m_nErrNum)
              //get failed row numbers into the array
              for (int i = 0; i < m_nErrNum; i++)
                   //initiallize error handles               OCIHandleAlloc((dvoid*)m_pEnvHandle, (dvoid**)&m_pErrorHndl,
                        OCI_HTYPE_ERROR, (size_t)0, (dvoid**)0);
                   OCIParamGet(m_pErrHandle, OCI_HTYPE_ERROR, m_pErrHandle2, (void**)&m_pErrorHndl[i], i);
                   OCIAttrGet (m_pErrorHndl[i], OCI_HTYPE_ERROR, &m_pRowOff[i], 0,
                                            OCI_ATTR_DML_ROW_OFFSET, m_pErrHandle2);
    now, if batch insert is executed, eg, there are 10 records to be inserted, thus m_nArrayLength is set to be 10. There are 5 records of the 10 have exist in database, so some of insert operations will fail. After execution, m_nErrNum is 5, and i can get the failed row numbers.Everything seems go well.
    However, if batch updata is excuted, eg, 10 records to be updated, m_nArrayLength is set to be 10, and also there are 5 records of the 10 have exist in database. After execution, the OCIStmtExecute() returns 1, m_nErrNum got by
    OCIAttrGet((dvoid *)m_pStmtAll,OCI_HTYPE_STMT,&m_nErrNum,
              0,OCI_ATTR_NUM_DML_ERRORS, m_pErrHandle2)
    is 0, and m_nSucNum is 5. Why?? how can I get the rows that fail? i have to know which rows do not exist in database??

  • USE sequence.nextval in SQL statement

    Hi,
    I want to use SEQUENCE_name.NEXVAL in our query.
    But it gives error
    ora-02287: sequence number not allowed here
    Select distinct dd.agreementid,dd.cityid,dd.bankid,dd.bankbranchid,zz.bankbranchdesc,
    account_no,account_type,Sysdate,'A',Null,'1001',Sysdate,NULL,NULL,
    ELEC_PMNT_SEQ.Nextval seq_num
    From pdi.pdi_instr_d_tmp dd,
    pdi.pdi_bankbranch_m zz,
    pdi.pdi_bankaccount_tmp t
    Where t.agreementid = dd.agreementid
    And dd.cityid = zz.cityid
    And dd.bankid = zz.bankid
    And dd.bankbranchid= zz.bankbranchid
    And dd.mc_status = 'M' And dd.status = 'M' And instr_type <> 'P'
    Thanks & Regards
    K S Ratan

    You can use a subquery, but maybe have you need an order by clause ?
    SQL> ed
    Wrote file afiedt.buf
      1* select distinct username, MySeq.nextval from dba_users
    SQL> /
    select distinct username, MySeq.nextval from dba_users
    ERROR at line 1:
    ORA-02287: sequence number not allowed here
    SQL> ed
    Wrote file afiedt.buf
      1  select a.*, MySeq.nextval
      2* from (select distinct username from dba_users order by username) a
    SQL> /
    USERNAME                          NEXTVAL
    DBSNMP                                  1
    H89UCBAC                                2
    OUTLN                                   3
    PEOPLE                                  4
    PS                                      5
    SYS                                     6
    SYSTEM                                  7
    7 rows selected.
    SQL> /
    USERNAME                          NEXTVAL
    DBSNMP                                  8
    H89UCBAC                                9
    OUTLN                                  10
    PEOPLE                                 11
    PS                                     12
    SYS                                    13
    SYSTEM                                 14
    7 rows selected.Is this do you want ? Sequence will increment on each query execution, or did you want the number of output line to have the same result on each sql execution :
    SQL> ed
    Wrote file afiedt.buf
      1  select a.*, rownum
      2* from (select distinct username from dba_users order by username) a
    SQL> /
    USERNAME                           ROWNUM
    DBSNMP                                  1
    H89UCBAC                                2
    OUTLN                                   3
    PEOPLE                                  4
    PS                                      5
    SYS                                     6
    SYSTEM                                  7
    7 rows selected.
    SQL> /
    USERNAME                           ROWNUM
    DBSNMP                                  1
    H89UCBAC                                2
    OUTLN                                   3
    PEOPLE                                  4
    PS                                      5
    SYS                                     6
    SYSTEM                                  7
    7 rows selected.
    SQL> Nicolas.
    Sorry Laurent, you've already showed that works with subquery...
    Message was edited by:
    N. Gasparotto

  • Use of Distinct in sql.

    Hi,
    Pl tell me
    How to use Distinct in SQL ?

    You use distinct to get rid of duplicate values from the query result. Something like this.
    SQL> select deptno from emp;
        DEPTNO
            20
            30
            30
            20
            30
            30
            10
            20
            10
            30
            20
            30
            20
            10
    14 rows selected.
    SQL> select distinct deptno from emp;
        DEPTNO
            30
            20
            10
    SQL>

Maybe you are looking for

  • Bb style as a modem

    Hi Can anybody please tell is there any setting to be done to use my bb style as an evdo modem.In my phone I am getting evdo speeds but when work as a modem it is giving cdma 1x speed only? My carrier is reliance india.

  • I am new to LabView. I need an example VI for doing RF third intermod measurements.

    I am using 2 Anritsu 2-40 GHz, and an Agilent Spectrum analyzer. I am in need of an example VI to get me started, since a am new to LabView.

  • Proxy Authentication Compilation Error

    Hi Java Expert, I am sampling the following code from http://www.javaworld.com/javaworld/javatips/jw-javatip46.html in an effort to authenticate the proxy that is situated behind the firewall: C:\Documents and Settings\htran\DnldURL\src\proxy\URLPass

  • Why did my upgrade not happen when I selected it?

    Firefox indicated my version was old. Menu showed area to click for upgrade. Upgrade appeared to "load" and when complete there was no new version. The message indicated I should click to "install" new version. This was done. Machine was restarted. O

  • BOOK: Generate ALWAYS makes page count even

    Hi everyone, Using FM8.0.4 on Win XP Pro SP3. I create a set of documents. In each document, I set the pagination to "Delete Empty Pages". I put all the documents into a book. In the book file, I set the pagination property for each document to "Dele