Query : first and last 25 records of a table

Hi @ll,
i am going to write a query for a report. Therefor i need the first and last 25 records of a table. Does anyone got an idea for a solution ? I was trying to achieve this by using a WHERE clause. Here is a part of the query :
SELECT
TOP 10 T1.[ItemCode], DATEPART(mm, T1.[DocDate])   [.....]
FROM FROM INV1 T1
Where T1.[DocDate] >= Cast('2009  [......] AND
T1.ItemCode = (
SELECT TOP 10 T40.[ItemCode]
FROM DBO.OINM
WHERE Where T40.[DocDate] >= Cast('2009-04-01 00:00:00' AS datetime)
AND T40.[DocDate] <= Cast('2009-04-30 00:00:00' AS datetime)
GROUP BY T1.[ItemCode], DATEPART(mm, T40.[DocDate])
ORDER BY SUM(T1.[TotalSumSy]) ASC)
The where part i would use twice, once for ascending the other one for descending. But it does not work.
Any ideas ?
Regards Steffen

Hi,
Union was the keyword, that i was searching for. It is a nice way, but not practible.
We are using coresuite for generating reports, and there were a nice possibility to connect diffrent queries.
Thanks for your suggestion.
Regards Steffen

Similar Messages

  • SQL query to get last 10 records in the table?

    Hi,
    Can anyone tell me the SQL query to get last 10 records in the table?
    Thanks!!
    MCP

    Please, define what "last" means. Sets are unordered by definition, so if you want to retrieve rows from a table in a specific order you need to specify what that order is - e.g. by maintaining a value in a column (or a combination of columns) that you can use in the ORDER BY clause of the SELECT statement.
    If, for instance, you kept the time when the row was inserted in a special column (InsertedTime), you could use this in your query like this:
    select top (10)
      <column list>
      from <table or view>
      where <restriction(s)>
      order by InsertedTime desc;
    ML
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Format first and last record of result query

    Hello
    I have the following query
    <tt>select 1 seq, 'This is First record' data from dual union all
    select 2, 'Data ' || tname from tab union all
    select 3, 'This was last record Last record' from dual
    order by 1</tt>
    When i spool this statement to a listfile with col seq noprint option i get:
    This is First record
    Data MLA_ACCESS_LIST
    Data MLA_APPLICATIONS
    Data MLA_VPD_PCK
    Data MLA_VPD_TABLES
    This was last record Last record
    But i want:
    This is First record MLA_ACCESS_LIST
    Data MLA_APPLICATIONS
    Data MLA_VPD_PCK
    MLA_VPD_TABLES This was last record Last record
    I tried it with 1 statement with usage of lead and lag, because first and last record have to differ from the other result records. But i get ORA-30484: missing window specification for this function
    Is this possible with 1 statement or am i doomed to edit the results by myself?
    Thanks Auke

    select case row_number() over (order by tname)
    when 1 then 'This is the First record '
    end || tname ||
    case row_number() over (order by tname desc)
    when 1 then ' This was the last record'
    end
    from tab
    order by tname
    hth

  • Select first and last records in grouped results - Oracle 11g

    Say I have the following information in an Oracle 11g table:
    Qty
    Production order
    Date and time
    20
    00000000000000001
    12-JAN-14 00:02
    20
    00000000000000001
    12-JAN-14 00:05
    20
    00000000000000001
    12-JAN-14 00:07
    20
    00000000000000001
    13-JAN-14 00:09
    30
    00000000000000002
    12-JAN-14 00:11
    30
    00000000000000002
    12-JAN-14 00:15
    30
    00000000000000002
    12-JAN-14 00:20
    30
    00000000000000002
    14-JAN-14 00:29
    I would like to write a query that would return the following:
    Qty
    Production order
    First
    Last
    80
    00000000000000001
    12-JAN-14 00:02
    13-JAN-14 00:09
    120
    00000000000000002
    12-JAN-14 00:11
    14-JAN-14 00:29
    That is, the sum of the Qty column grouped by Production order, and the date/time of the first and last records for each Production order.
    I came up with a query that yielded this result:
    Qty
    Production order
    First
    Last
    80
    00000000000000001
    12-JAN-14 00:02
    14-JAN-14 00:29
    120
    00000000000000002
    12-JAN-14 00:02
    14-JAN-14 00:29
    Which means that the First and Last columns show the overall first and last date / time of the whole table. Please note that this is a dummy table. Sorry I am now allowed to write the actual query
    I came up with since work policies do not allow me to share it. Also, I tried with windowing functions such as rank()and row_number() but my user does not have enough privileges to do so.
    Any help or hints will be greatly appreciated.

    Due to the fact that Oracle does not record the rows in any particular order, it would be wrong that the "first date" would be the first row processed by the query.
    Therefore you would have to supply some other column if you do not want to consider the table as ordered by date.
    Also, any analytical functions will need you to supply the "order by" and if its the date, then just a simple query will do:
    SQL>WITH Tab1 (Qty, Production_Order, Pdate)
      2       AS (SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:02', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      3           SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:05', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      4           SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:07', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      5           SELECT 20, '00000000000000001', TO_DATE ( '13-JAN-14 00:09', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      6           SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:11', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      7           SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:15', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      8           SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:20', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
      9           SELECT 30, '00000000000000002', TO_DATE ( '14-JAN-14 00:29', 'DD-MON-YY HH24:MI') FROM DUAL)
    10  SELECT   SUM ( Qty), Production_Order, MIN ( Pdate), MAX ( Pdate)
    11      FROM Tab1
    12  GROUP BY Production_Order
    13* ORDER BY Production_Order
    SQL> /
      SUM(QTY) PRODUCTION_ORDER     MIN(PDATE)                    MAX(PDATE)
            80 00000000000000001    12-Jan-2014 00:02:00          13-Jan-2014 00:09:00
           120 00000000000000002    12-Jan-2014 00:11:00          14-Jan-2014 00:29:00

  • How to get the first and last record

    Hai All
    I have table called T1 and there are more than 8 lakhs records and i have a column called Timestamp so i need to get the first record value and time stampvalue and last record and time stamp value so that i can conclude that For Example
    form 13 june to 15 june data are here
    Kind Regards
    SrikkanthM

    Something like this can also indicate the first and last rows as you query...
    SQL> select empno, ename, hiredate
      2        ,case row_number() over (order by hiredate)
      3           when 1 then 'First Row'
      4           when count(*) over () then 'Last Row'
      5         end as flag
      6  from emp;
         EMPNO ENAME      HIREDATE            FLAG
          7369 SMITH      17/12/1980 00:00:00 First Row
          7499 ALLEN      20/02/1981 00:00:00
          7521 WARD       22/02/1981 00:00:00
          7566 JONES      02/04/1981 00:00:00
          7698 BLAKE      01/05/1981 00:00:00
          7782 CLARK      09/06/1981 00:00:00
          7844 TURNER     08/09/1981 00:00:00
          7654 MARTIN     28/09/1981 00:00:00
          7839 KING       17/11/1981 00:00:00
          7900 JAMES      03/12/1981 00:00:00
          7902 FORD       03/12/1981 00:00:00
          7934 MILLER     23/01/1982 00:00:00
          7788 SCOTT      19/04/1987 00:00:00
          7876 ADAMS      23/05/1987 00:00:00 Last Row
    14 rows selected.
    SQL>

  • First and Last Record

    Hi everybody,
    I have problem with first and last record.How can I specified that current record is first and last record.
    it means that is any statement exist that determine :System.first_record is equal to :System.last_record.
    It's very emergancy.
    Thanks for your attention and your help.
    /Shiva

    You can try this:
    if :system.cursor_record = '1' and :system.last_record = 'TRUE' then
    -- this is the only record in block
    end if;
    Hi everybody,
    I have problem with first and last record.How can I specified that current record is first and last record.
    it means that is any statement exist that determine :System.first_record is equal to :System.last_record.
    It's very emergancy.
    Thanks for your attention and your help.
    /Shiva

  • Fetch first and last record together

    Hi All,
    I want to fetch first and last records. I have done through ROWNUM, but I need some alternative ways, may be through RANK function.
    Please help on this.
    here sample data:
    WITH t AS
    (SELECT 100 sid, 'ABC' SNAME,  4 status_id, SYSDATE + 1/24 start_date FROM dual UNION ALL
    SELECT 100  sid, 'ABC' SNAME,  5 status_id ,SYSDATE + 2/24 start_date FROM dual UNION ALL
    SELECT 100  sid, 'ABC' SNAME,  6 status_id ,SYSDATE + 3/24 start_date FROM dual UNION ALL
    SELECT 100  sid, 'ABC' SNAME,  7 status_id ,SYSDATE + 3/24 start_date FROM dual UNION ALL
    SELECT 100  sid, 'ABC' SNAME,  8 status_id ,SYSDATE + 4/24 start_date FROM dual)
    SELECT * FROM t ORDER BY start_date;Thanks,

    if you want all the info on the same row.
    /* Formatted on 10/19/2011 7:06:50 AM (QP5 v5.149.1003.31008) */
    WITH t AS (SELECT 100 sid,
                      'ABC' SNAME,
                      4 status_id,
                      SYSDATE + 1 / 24 start_date
                 FROM DUAL
               UNION ALL
               SELECT 100 sid,
                      'ABC' SNAME,
                      5 status_id,
                      SYSDATE + 2 / 24 start_date
                 FROM DUAL
               UNION ALL
               SELECT 100 sid,
                      'ABC' SNAME,
                      6 status_id,
                      SYSDATE + 3 / 24 start_date
                 FROM DUAL
               UNION ALL
               SELECT 100 sid,
                      'ABC' SNAME,
                      7 status_id,
                      SYSDATE + 3 / 24 start_date
                 FROM DUAL
               UNION ALL
               SELECT 100 sid,
                      'ABC' SNAME,
                      8 status_id,
                      SYSDATE + 4 / 24 start_date
                 FROM DUAL)
      SELECT sid,
             sname,
             MIN (status_id) KEEP (DENSE_RANK FIRST ORDER BY start_date) min_status,
             MIN (start_date) min_dt,
             MAX (status_id) KEEP (DENSE_RANK FIRST ORDER BY start_date DESC)
                max_status,
             MAX (start_date) max_dt
        FROM t
    GROUP BY sid, sname
    SID     SNAME     MIN_STATUS     MIN_DT     MAX_STATUS     MAX_DT
    100     ABC     4     10/19/2011 8:05:54 AM     8     10/19/2011 11:05:54 AMEdited by: pollywog on Oct 19, 2011 7:11 AM

  • Query to find first and last call made by selected number for date range

    Hi,
    query to find first and last call made by selected number for date range
    according to filter:
    mobile_no : 989.....
    call_date_from : 25-april-2013
    call_date_to : 26-april-2013
    Please help

    Hi,
    It sounds like you want a Top-N Query , something like this:
    WITH    got_nums   AS
         SELECT     table_x.*     -- or list columns wanted
         ,     ROW_NUMBER () OVER (ORDER BY  call_date      ) AS a_num
         ,     ROW_NUMBER () OVER (ORDER BY  call_date  DESC) AS d_num
         FROM     table_x
         WHERE     mobile_no     = 989
         AND     call_date     >= DATE '2013-04-25'
         AND     call_date     <  DATE '2013-04-26' + 1
    SELECT  *     -- or list all columns except a_num and d_num
    FROM     got_nums
    WHERE     1     IN (a_num, d_num)
    ;This forum is devoted to the SQL*Plus and iSQL*Plus front ends. This question doesn't have anything to do with any front end, does it? In the future, you'll get better response if you post questions like this in the PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the SQL forum FAQ {message:id=9360002}

  • SQL (first and last record)

    Hi All,
    WITH t AS
    SELECT 100 region_id, 1001 Client_Id, 'client 1' Client_Name, 1 Status_id, 'progress' Status_name, SYSDATE + 1 Start_Date, SYSDATE + 1 End_Date FROM dual UNION ALL
    SELECT 100 region_id, 1001 Client_Id, 'client 1' Client_Name, 2 Status_id, 'hold' Status_name ,SYSDATE + 1 Start_Date, SYSDATE + 1 End_Datet FROM dual UNION ALL
    SELECT 100 region_id, 1001 Client_Id, 'client 1' Client_Name, 3 Status_id ,'reject' Status_name, SYSDATE + 1 Start_Date, SYSDATE + 1 End_Date FROM dual UNION ALL
    SELECT 200 region_id, 1002 Client_Id, 'client 2' Client_Name, 1 Status_id, 'progress' Status_name, SYSDATE + 1 Start_Date, SYSDATE + 1 End_Date FROM dual UNION ALL
    SELECT 200 region_id, 1002 Client_Id, 'client 2' Client_Name, 2 Status_id, 'hold' Status_name ,SYSDATE + 1 Start_Date, SYSDATE + 1 End_Datet FROM dual UNION ALL
    SELECT 200 region_id, 1002 Client_Id, 'client 2' Client_Name, 3 Status_id ,'reject' Status_name, SYSDATE + 1 Start_Date, SYSDATE + 1 End_Date FROM dual UNION ALL
    SELECT 200 region_id, 1002 Client_Id, 'client 2' Client_Name, 3 Status_id ,'progress' Status_name, SYSDATE + 1 Start_Date, SYSDATE + 1 End_Date FROM dual
    SELECT * FROM t;Desired output:
    REGION_ID     CLIENT_ID     CLIENT_NAME     STATUS_ID     STATUS_NAME     START_DATE                    END_DATE
    100     1001     client 1                      1                     progress                     9/3/2011 12:26               9/3/2011 12:26
    100     1001     client 1                      3                     reject                     9/3/2011 12:26                     9/3/2011 12:26
    200     1002     client 2                      1                     progress                     9/3/2011 12:26                     9/3/2011 12:26thanks,

    Hi,
    Like Sven, I don't understand why you only want one output row for client_id=1002. Also, I don't understand what order determine "first" and "last". It's hard to guess because so many of the columns have the same value on every row.
    My best guess is that status_id plays a part in deciding who is "first" and "last", and that you don't want to include ties (multiple rows with a equal claim to being "first" or "last") in the output.
    WITH     got_analytics     AS
         SELECT     t.*     -- or whatever columns you want to display
         ,     ROW_NUMBER () OVER ( PARTITION BY  region_id
                             ,             client_id
                             ,             client_name
                             ORDER BY        end_date
                             ,             start_date
                             ,             status_id
                            )     AS a_num
         ,     ROW_NUMBER () OVER ( PARTITION BY  region_id
                             ,             client_id
                             ,             client_name
                             ORDER BY        end_date     DESC
                             ,             start_date     DESC
                             ,             status_id     DESC
                            )     AS d_num
         ,     COUNT (*)     OVER ( PARTITION BY  region_id
                             ,             client_id
                             ,             client_name
                             ,             end_date     -- NOTE: no ORDER BY
                             ,             start_date
                             ,             status_id
                            )     AS cnt
         FROM     t
    --     WHERE     ...     -- if you need any filtering, this is where it goes
    SELECT       region_id, client_id, client_name, status_id, start_date, end_date
    FROM       got_analytics
    WHERE       (     a_num     = 1
           OR     d_num     = 1
    AND       cnt     = 1
    ORDER BY  region_id, client_id, client_name, start_date, end_date, status_id
    ;If client_name and region_id depend on client_id, then you don't need to include them in the PARTITION BY clauses. Depending on your requirements, you may not want them in the PARTITION BY clauses even if they are independent of client_id. Then again, you may not want client_id in th PARTITION BY clauses. It all depends on what you're trying to do.

  • Simple Query Question - How do I return the Last 3 records of a Table?

    Question.
    For example, I have a table that has 50 records.
    How do I, specify in SQL to only return the last 3 records of the table.
    Select a.* from table a where ????

    I was just trying to show an example to a friend on
    how something like this would work and if it was even possible. But it won't work. Here's a simple example:
    SQL> create table emp
      2  (id)
      3  as
      4  select object_id
      5  from   all_objects
      6  order  by object_id;
    Table created.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
         40830      55891
         40831      55892
         40832      55893So far, so good. These are the "last 3" rows inserted. Now delete a bunch of rows and insert 3 new ones:
    SQL> delete emp where id < 40000;
    33423 rows deleted.
    SQL> commit;
    Commit complete.
    SQL> insert into emp values (60000);
    1 row created.
    SQL> insert into emp values (60001);
    1 row created.
    SQL> insert into emp values (60002);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
          7410      55891
          7411      55892
          7412      55893Here's the problem. Even though the "last 3 rows" are 60000 - 60002, I still get the same ones as the first query.

  • How can I display the first and last name using a paramater as employee ID?

    Hi SAP,
    I have a parameter that is called {? Employee ID}.   What I want to do is display the first and last name based on the employee ID value entered in {? Employee ID} in the page header of the report.  Right now, when I put the following formula in the page header only some pages get the right result while other pages dont....
    if table.employeeid = {? Employee ID} then
    table.firstname" "table.lastname
    It appears as though if the first record in the details section on the beginning of each page happens to be the employee under {? Employee ID} then it prints it correctly, if it isn't I get a null value in the page header.
    Anyone have any ideas?
    Z

    Hi Try this,
    Whileprintingrecords;
    if ={?EmpID} then
    Also check the option "Default values for null" in the formula editor.
    Regards,
    Vinay

  • Finding first and last members of a group set

    Is there any example how to use 'first' and 'last' functions in an sql query ?
    I have tried to execute a query like this on the scott.emp table :
    select deptno,min(sal),max(sal),first(sal) from emp group by deptno;
    but I always get this message:
    ERROR at line 1:
    ORA-00904: "FIRST": invalid identifier
    btw I use Oracle RDBMS ver 9.1.0.3 for Solaris in my server.
    tx for your help
    sjarif

    Syarif,
    The FIRST and LAST functions, which became available with 9i, are used to find the first or last member of a ranked set. I'm not sure exactly what you are trying to do, but I can show you a query that should work (I don't have 9i handy at the moment). This query should give you the departments with the highest (first) and lowest (last) aggregate salaries:
    select deptno,
    min(deptno)
    keep (dense_rank first order by sum(sal) desc) highest_sal,
    min(deptno)
    keep (dense_rank last order by sum(sal) desc) lowest_sal
    from emp
    group by deptno
    Is there any example how to use 'first' and 'last' functions in an sql query ?
    I have tried to execute a query like this on the scott.emp table :
    select deptno,min(sal),max(sal),first(sal) from emp group by deptno;
    but I always get this message:
    ERROR at line 1:
    ORA-00904: "FIRST": invalid identifier
    btw I use Oracle RDBMS ver 9.1.0.3 for Solaris in my server.
    tx for your help
    sjarif

  • First and Last Name Swapping

    Address book in Leopard does not have the Swap First Name with Last Name in the drop down menu on the desk top tool bar. All my addresses are indexed with last name first, and I want to continue to keep my records this way. Does anyone know where the Swap First and Last Name control is in Leopard Address Book? Thanks

    Hi:
    The menu items have been renamed somewhat in Leopard. I don't have Leopard in front of me at the moment, but this option should still be available on a per-card basis (or per a selection of cards) within Address Book's Card menu. And the global setting in preferences will affect all of the cards that don't have this setting customized individually.

  • E-Recruitment business partner objects missing First and Last Name

    Hi,
    We are on Netweaver 2004s and ERecruitment EHP3...it's installed on production but not activated.  We are finding a bunch of BP records that exist where there is no First and Last Name on them, however the CP object does have this data.  We can't figure out what is causing this to happen to some candidates?  It appears to only be the case on External/Unregistered Candidates.
    Thanks,
    Michelle

    Hi Michelle,
    could you share the number of the note?
    Kind regards
    Roman

  • How to find first and last date of a fiscal week using SQL

    Hello,
    I want information about FISCAL Week, means a Week based on ISO standard. I know format strings ‘IW’ or ‘IYYY’ gives fiscal week and fiscal year respectively from a given date. But I want to find the first and last date of a fiscal week. Say suppose I have a fiscal week is 2, and fiscal year is 2008, how to find the start and end date of the given fiscal week.
    Any kind of help would be greatly appreciable.
    Thanks,
    Prince

    davide gislon wrote:
    The following query evaluate the begin of a fisical week, where &year and &week are respectively the year and week you want to calculate.
    To evaluate the end of the week you have to add 6.
    Note that my database is set to have monday as day number 1 of the week, and sunday as day number 7; if your database settings are different you should modify the query accordingly.
    SELECT CASE TO_CHAR(TO_DATE('&year','YYYY'),'D')
    WHEN '1' THEN TO_DATE('&year','YYYY')+((&week-1)*7)
    WHEN '2' THEN TO_DATE('&year','YYYY')+((&week-1)*7-1)
    WHEN '3' THEN TO_DATE('&year','YYYY')+((&week-1)*7-2)
    WHEN '4' THEN TO_DATE('&year','YYYY')+((&week-1)*7-3)
    WHEN '5' THEN TO_DATE('&year','YYYY')+((&week-1)*7+3)
    WHEN '6' THEN TO_DATE('&year','YYYY')+((&week-1)*7+2)
    WHEN '7' THEN TO_DATE('&year','YYYY')+((&week-1)*7+1)
    END BEGIN_FISICAL_WEEK
    FROM DUAL
    Hope this is helpful.
    Cheers,
    Davide
    Edited by: davide gislon on 08-Jan-2009 07:19Your query does nothing you say it does. TO_DATE('&year','YYYY') returns first day of the current month for year &year. And the only reason it returns January 1, &year is that we are currently in January:
    SQL> select TO_DATE('&year','YYYY') from dual
      2  /
    Enter value for year: 2005
    old   1: select TO_DATE('&year','YYYY') from dual
    new   1: select TO_DATE('2005','YYYY') from dual
    TO_DATE('
    01-JAN-05
    SQL> As soon as we roll into February:
    SQL> alter system set fixed_date = '2009-2-1' scope=memory
      2  /
    System altered.
    SQL> select sysdate from dual
      2  /
    SYSDATE
    01-FEB-09
    SQL> select TO_DATE('&year','YYYY') from dual
      2  /
    Enter value for year: 2005
    old   1: select TO_DATE('&year','YYYY') from dual
    new   1: select TO_DATE('2005','YYYY') from dual
    TO_DATE('
    01-FEB-05
    SQL> alter system set fixed_date = NONE scope=both
      2  /
    System altered.
    SQL> select sysdate from dual
      2  /
    SYSDATE
    08-JAN-09
    SQL> But even if TO_DATE('&year','YYYY') would always return January 1, &year, or you would fix it to TO_DATE('0101&year','MMDDYYYY') it still would be wrong. ISO week rules are
    If January 1 falls on a Friday, Saturday, or Sunday, then the week including January 1 is the last week of the previous year, because most of the days in the week belong to the previous year.
    If January 1 falls on a Monday, Tuesday, Wednesday, or Thursday, then the week is the first week of the new year, because most of the days in the week belong to the new year.Therefore, next year:
    SQL> DEFINE YEAR=2010
    SQL> DEFINE WEEK=1
    SQL> ALTER SESSION SET NLS_TERRITORY=GERMANY -- enforce Monday as first day of the week
      2  /
    Session altered.
    SQL> SET VERIFY OFF
    SQL> SELECT CASE TO_CHAR(TO_DATE('0101&&year','MMDDYYYY'),'D')
      2  WHEN '1' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7)
      3  WHEN '2' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-1)
      4  WHEN '3' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-2)
      5  WHEN '4' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-3)
      6  WHEN '5' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+3)
      7  WHEN '6' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+2)
      8  WHEN '7' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+1)
      9  END BEGIN_FISICAL_WEEK
    10  FROM DUAL
    11  /
    BEGIN_FI
    04.01.10
    SQL> SELECT TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') FROM DUAL
      2  /
    TRUNC(TO
    28.12.09
    SQL> 2 user10772980:
    Use:
    SELECT  TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') + (&&week-1)*7 FISCAL_YEAR_&&YEAR._WEEK_&&WEEK
      FROM  DUAL
    FISCAL_YEAR_2010_WEEK_1
    28.12.09
    SQL> SY.

Maybe you are looking for

  • Problem transferring my iTunes library from my old laptop to new one

    I got a new iPad for Xmas to replace an old laptop not realising I would still have to have a laptop or PC for my main iTunes library. I have got round ths by creating my own area on my partner's laptop & have installed my iTunes library on there. Ho

  • Sap_wapi_start_workflow

    hi to all in my workflow there is a multiline container element (ZCLAIM)which contain a structure ZCLAIMREIQ ZCLAIMEXPTYPE ZCLAIMDATE ZCLAIMBILLNO ZCLAIMDESC ZCLAIMAMT Now via abap program i am initiating my workflow by fn mod SAP_WAPI_START_WORKFLOW

  • 2LIS_04_P_ARBPL and Write Optimized

    Hi All, I have a need to load 2LIS_04_P_ARBPL into a write optimized DSO due to performance reason and since this data source has 'reversal indicator' the write optimized does not handle it. The standard DSO will take care of 0RECORDMODE, but not wri

  • Dvd: 90 fast encode output file is not an mpeg-2

    I have a 40 minute video that when I use the DVD: 90 minute fast encode codec, it outputs it to a blank file. It doesn't have the mpeg-2 icon as it should. When I click on it, it opens up the batch window from compressor. Not a clue? This is the firs

  • Lilbrary and Duplicated HTML Tags

    Hi, I have built libraries and templates. each library is viewed correctly in Design mode, but after all libraries are merged into a page, it is not displayed correctly. I have found there are so many duplicated <div> tags. Anyone has a solution? Tha