First 2 Higher Number and Last 2 Lower Number

Hi Experts
I have a table with the name T there are some numeric values i want to select First 2(60, 50) Higher numbers and Last 2 (10 and 20) Lower numbers with query.
I'm using Oracle 10g R2
C1
     10
     20
     30
     40
     50
     60
Please help me in this regard
Regards,
Nasir.

With this solution you scan your table one time.
REgards Salim.
select c1
from (
            select c1,find
            from t
            model
            dimension by ( row_number()over(partition by 1 order by c1) rn)
              measures( c1, 0 find, count(1)over(partition by 1) cpt)
             ( find[any]= case when cv(rn) in (1,2,cpt[1],cpt[1]-1) then 1 else 0 end )
where find=1
SQL> with t  as ( select        10 C1 from dual union all
  2   select 20  from dual union all
  3   select 30 from dual union all
  4   select 40 from dual union all
  5   select 50 from dual union all
  6   select 60 from dual )
  7  select c1
  8  from (
  9              select c1,find
10              from t
11              model
12              dimension by ( row_number()over(partition by 1 order by c1) rn)
13                measures( c1, 0 find, count(1)over(partition by 1) cpt)
14               ( find[any]= case when cv(rn) in (1,2,cpt[1],cpt[1]-1) then 1 else 0 end )
15          )
16  where find=1
17  /
        C1
        10
        20
        50
        60
SQL>

Similar Messages

  • Why did myEE ask for my sort number and last 4 digits of my debit card

    When trying to set up myEE I was asked for my sort number and last four digits of my debit card, I got the myEE app from the App Store for my ipad

    It asks you for this information if you say you are the bill payer when setting up your account. This information is used to check and match the details with EE's payment systems so you can then access your bills/payments online.

  • How do you add a mobile number and a home number to a contact on a 4S

    How do you add a mobile number and a home number to a contact on an iPhone4S?

    First add the mobile number. Once you've done that there should be another field that shows 'iPhone". Tap on 'iPhone' and change it to 'Home' then input the home number.

  • How to  Trunc one number and Round another number in different row?

    Here is a sample where I take a percent of a number.
    <code>
    SELECT 40*.5 AONE, 'A' aname
    FROM DUAL
    UNION ALL
    SELECT 121*.5 AONE, 'B' aname
    FROM DUAL
    UNION ALL
    SELECT 121*.5 AONE, 'C' aname
    FROM DUAL
    UNION ALL
    SELECT 80*.5 AONE, 'D' aname
    FROM DUAL
    </code>
    this gives me
    20 A
    60.5 B
    60.5 C
    40 D
    I want to TRUNC one number and ROUND another number where the number has a
    "0.5" so I would have
    20 A
    61 B
    60 C
    40 D
    I will have more than 4 records, just trying to keep it simple.
    Suggestions?
    TIA
    Steve42
    Edited by: Steve42 on Dec 5, 2011 1:44 PM

    I missed you only want to truncate/round where value fractional part is .5:
    WITH SAMPLE_TABLE AS (
                          SELECT 40*.5 AONE, 'A' aname FROM DUAL UNION ALL
                          SELECT 121*.5 AONE, 'B' aname FROM DUAL UNION ALL
                          SELECT 121*.5 AONE, 'C' aname FROM DUAL UNION ALL
                          SELECT 80*.5 AONE, 'D' aname FROM DUAL
    SELECT  CASE MOD(ABS(AONE),1)
              WHEN .5 THEN
                        CASE MOD(ROW_NUMBER() OVER(ORDER BY CASE MOD(ABS(AONE),1) WHEN .5 THEN ANAME END NULLS LAST),2)
                          WHEN 1 THEN TRUNC(AONE)
                          WHEN 0 THEN ROUND(AONE)
                        END
              ELSE AONE
            END AONE,
            ANAME
      FROM  SAMPLE_TABLE
      ORDER BY ANAME,
               ROW_NUMBER() OVER(ORDER BY CASE MOD(ABS(AONE),1) WHEN .5 THEN ANAME END NULLS LAST)
          AONE A
            20 A
            60 B
            61 C
            40 D
    SQL> SY.
    Edited by: Solomon Yakobson on Dec 5, 2011 5:05 PM

  • Report to find a material by a mfr part number and old material number

    Hi,
    Is there any standard report to find a material by a mfr part number and old material number ?
    For the moment, we are using MM03 to search articles by these selection criterion.
    Thanks,
    Julien Girard

    Hi
    As there is no stsndard report use the SQVI to find out the details, It is very simple , please follwo the below steps.
    Use Txn SQVI, enter the Quick view field say- ZMNFR and click the  create button, Enter the title in the next screen i.e Report name- Say - Manufacturer's Part No. Details, in the same screen you need to enter  MARA  for the data from table/database view, please leave the 1. data source as Table only and the radio button as Basis mode only.  Click the tick mark , you will go to the next screen,
    You will notice Quick viewer Intial screen
    Open the node general material data
    Select the Buttons besides the fields MARA-MATNR for material number, MARA-MFRPN for manufacturers part number, and MARA-BISMT for old material number. You can include any other field if you wish to have in your output. You will notice two check boxes against each field, one is for input screen field and the other is for outputf field. But currently you do not bother about and select both the check boxes or any other field you wish to have as input and output as well. Once selected all the fields afer clicking the check boxes save the total arrangement. and then in the same screen use the execute button or use F8 to find out your report input screen.
    Now enter the Material number for which you wish to know other two details in the report and execute again you will find the report output.
    Please ensure that you are maintaining both the details in material master basic data1 and purchasing  view if you wish to get  out output
    Best regards
    SAM
    Edited by: samuel mendis on Apr 8, 2009 6:52 AM

  • Invoice Number and Performa invoice number

    Hi all
      I want to get the combination of invoice Number and Performa invoice number, I have got the VBFA Table, but it’s very slow, any alternative program or function please help me
    Thanks
    Kanishka

    Try AC_DOCUMENT_RECORD. It returns all kind of accounting documents.

  • Download Error - Contact customer support. Indesign wont load application have gone from the control panel. CS photoshop loads and wants a serial number - and my serial number dosent work?

    Download Error - Contact customer support. Indesign wont load application have gone from the control panel. CS photoshop loads and wants a serial number - and my serial number dosent work?

    Hello Bradley,
    sometimes the "opm.db file" is the culprit. In this case you should delete it.
    But as much as I regret it and as strange as it may seem I fear it's a challenge for Adobe's Creative Cloud Cleaner Tool.
    Sometimes - for whatever reasons - CC doesn't "want" to work. In this case you should CC completely delete and reinstall by help of Adobe Creative Cloud Cleaner Tool. (A try to uninstall by own resources is not enough!)
    I quote: ... helps resolve installation problems for Adobe Creative Cloud and Adobe Creative Suite (CS3-CS6) applications. The tool removes installation records for prerelease installations of Creative Cloud or Creative Suite applications. It does not affect existing installations of previous versions of Creative Cloud or Creative Suite applications.
    Please use: http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html   and follow the prescribed sequence of operations
    If necessary and for further questions click through http://helpx.adobe.com/contact.html or http://helpx.adobe.com/de/contact.html and if "open" please use chat, I had the best experiences.
    Good luck!
    Hans-Günter

  • Shipment document number and cost document number for vendor invoice

    Hi,
    Given a Vendor invoice number ( MIRO) how to find out the shipment number and cost docuemnt number?
    Regards,
    Krishna prasad.

    Hi,
    Please try using SREL_GET_NEXT_RELATIONS. Please try to search on SDN and you should find an example fo this. The only thing you need to pass is the Business Object Name for Vendor Invoice number. Or if you have an alternal field like even PO that you can pass , that will be of great help as well.
    You may want to take a look at:
    SREL_DISPLAY_LIST_OF_NEIGHBORS
    SREL_GET_NEXT_RELATIONS
    Pls reward points if useful.
    Thanks
    Ganesh.S

  • Purchase requistion number and line item number linkage with work order opr

    Hello,
    I want to know what is the link between Purchase requisition number along with its line item number with work order operation number.
    For the non stock component assign to Work order operation ( say operation 10) the PR get generated for that component which assign to that operation .
    in which table we can find that PR as input and output as Work order number along with its operation .
    In AFVC table if we put PR as input then it does not show any entry for that PR number?
    Regards
    Vaibhav

    HI Vaibhav,
    If you have the Work Order Number AUFNR, then you can get AUFPL from AFKO.
    Then Pass AUFPL to AFVC table to get BANFN(Purchase requisition number) and BNFPO(Item number of the purchase requisition in the order).
    Regards,
    Ravi

  • Line item number and ledger item number posted differently

    Hi Friends ,
      I have a BAPI for posting the documents in SAP from another system.This BAPI is using the standard BAPI -  'BAPI_ACC_DOCUMENT_POST' to post the documents.But when I post the document using this BAPI the line item number and ledger item number in the document are posted differently. ie . for line item no 1 ledger item is 24 .But when I am posting it directly it is same ie for line item no 1 ledger item no is also 1.Lot of other programs in our R/3 system is dependent in this logic.What could be the parameters in BAPI that could affect line item and ledager item ? Can anybody help me in finding out the reason for this ?
    Thanks in advance ,
    Joby

    Hi ,
    Anybody can help me on this issue ?
    Thanks in advance ,
    Joby

  • PO number and Finance doc number connection

    Hi Experts,
    In our project we got a requirement like we need to show fields from fs10n, fields are, GL account number,
    FI document number, PO number, Amount in local currency and PO description.
    I didnt see any datasource which bring PO number, FI GL account number and Finance document number together, so please guide me in this regards.
    how can i bring finance and purchase data together?? which is the appropriate data source for this?
    Thanks,
    urs raghu

    >
    ursraghu.bw wrote:
    > Hi Experts,
    >
    > In our project we got a requirement like we need to show fields from fs10n, fields are, GL account number,
    > FI document number, PO number, Amount in local currency and PO description.
    >
    > I didnt see any datasource which bring PO number, FI GL account number and Finance document number together, so please guide me in this regards.
    >
    > how can i bring finance and purchase data together?? which is the appropriate data source for this?
    >
    > Thanks,
    > urs raghu
    U can do a multprovider on both Purchasing and Finance InfoCube.
    In R/3, table BSEG has a field call EBELN. So I believe in BW you can use DataSource 0FI_GL_14 as it contains PO num, acct doc, etc. As long with these keys, it is easy to do a join or lookup DSO or even a multiprovider.
    hope it helps.

  • BOM Item number and the pr number created through network

    We can create PR through network. If we know the PR number and the item number, how do we find the BOM item number in the network?
    BOM item number
    Item number of the BOM components copied into the order.

    RSDB
    RSBD POSNR

  • Link between inv. number and accounting document number

    Hi Frnds,
    When i receive  a partial receipt (of an invoice) from a customer, i am getting the link between invoice number and accounting document number from a table (BSEG), but when i am receiving the final settlement amount from the customer, i m not getting the link between the inv. no. and accounting document number. Can anyone tell me how can i get the same?

    Hello,
    Try to prepare query based on tables BSIK, BSAK and BSEG. (Transaction code SQVI)
    Regards,
    Ravi

  • Link between Invoice verifycation number and Accounting Document number

    Dear All
                   I want the Link between invoice verifycation number (MIRO) an accounting document number the same MIRO. in which table the both two numbers avilable.
    How can identify. can any one tell me the table name for this
    Regards
    Kumar.

    Hi..
    What is the link or join condition for these two tables
    BKPF and RBKP. and RSEG and BSEG.
    In this i want to Accounting document number and invoice verifycation number in a single report.
    Regards
    Kumar

  • Link between invoice number and accounting document number

    Hi Frnds,
    When i receive a partial receipt (of an invoice) from a customer, i am getting the link between invoice number and accounting document number from a table (BSEG), but when i am receiving the final settlement amount from the customer, i m not getting the link between the inv. no. and accounting document number. Can anyone tell me how can i get the same?

    hi
    try these tcodes
    FBL5N
    FB02
    regards

Maybe you are looking for

  • Search not working in Catalog

    Hi, While seaching for an item in internal catalog with some key word, it is not giving any result. It it giving the message "no items found". TREX is running. But still search is not yeilding any output. In my preivous project we came across this si

  • Airport Card/Bluetooth Installation

    Hi. Was wondering if anyone could help provide links with easy to understand, clearcut (step by step pics are always nice) instructions on how to install an airport card and bluetooth into my G4 flatpanel? Or, is this something best left to professio

  • Financial Statement Generator in SAP FI

    Hi, Oracle has FSG that unables users to generate reports out of Oracle GL. Is there any equivalent report generator in SAP for users to create reports on ad-hoc basis. Thanks

  • How do I get rid of passcode to unlock screen. I do not want it

    I just downloaded ios7 and typed in a passcode, thinking it was just to use so others could not take my phone and delete stuff to use it for themselves. I did not know I had to use this passcode every time I wanted to get into my phone or my iPad. So

  • Apple sold extended warranty for ipod, will not honor it

    Apple sold me an extended warranty for my ipod that was manufactured by HP. I asked several times - are you sure you support this model? They said yes. At the time, it was still under its regular warranty and starting to have problems. I thought I ha