How to write the following UPDATE query

I have a table with data as below:

Subscriber IMSI imsi_rank
1123211
123123412
13324423
13424
15
2232131
2123212
2123123
24
25

Now, the data is dense and continuous for a SUBSRCIBER. Between there is no value for a SUBSCRIBER's IMSI null. However, where one or more IMSI is null, I need to update the table to move the IMSI values to the top of the IMSI_RANK.

Say for example for Subscriber 1, IMSI value 2312341 and 332442 is set to NULL value. So I need to write an application Update or PLSQL that will update the data as below.

Subscriber IMSI imsi_rank
1123211
13422
13
14
15
2232131
2123212
2123123
24
25

I use 11g.

You cannot perform SQL on any PL/SQL collection type. You need to loop through them and make the change.

Tags: Database

Similar Questions

  • How to write the following SQL

    I have a table with the following columns seq_no, customer_no, sales_person, card_type, NTB_Cust, paid_flag. He basically tells what a person sale that sold the customer what card, and if the customer is a New_To_Bank. Seq_no field is a sequence running. I need fill out the paid_flag as 1 or 0 according to certain rules.

    The first point to consider is that the card_type should be "PREFERRED" and NTB_Cust = "NTB".
    Then, if the sales_person has sold two cards that follow with the above criteria, in the same customer_no, then only the first will be marked with paid_flag = 1. If he sold 3 consecutive to the same customer cards, then the 1st and the 3rd will be marked as paid_flag = 1. If the sales_person has sold 4 cards to the same customer and then the 1st and the 3rd will be marked as paid_flag = 1. And so on.

    See below the expected value of paid_flag
    seq_no card_type NTB_Cust paid_flag customer_no sales_person
    XXX 999 FAVORITE NTB 1 1
    2 999 FAVORITE NTB XXX 0
    XXX 3 999 FAVORITE NTB 1
    4 999 PRESTIGE NTB XXX 0
    XXX 5 888 FAVORITE NTB 1
    XXX 6 888 FAVORITE OLD 0
    7 FAVORITE NTB 888 XXX 1

    Hello

    Try

    WITH T1
    AS
    (
    SELECT 1 seq_no, 'XXX' sales_person, 999 customer_no, 'PREFERED' card_type, 'NTB' NTB_Cust, 1 paid_flag FROM DUAL UNION ALL
    SELECT 2, 'XXX', 999, 'PREFERED', 'NTB', 0 FROM DUAL UNION ALL
    SELECT 3, 'XXX', 999, 'PREFERED', 'NTB', 1 FROM DUAL UNION ALL
    SELECT 4, 'XXX', 999, 'PRESTIGE', 'NTB', 0 FROM DUAL UNION ALL
    SELECT 5, 'XXX', 888, 'PREFERED', 'NTB', 1 FROM DUAL UNION ALL
    SELECT 6, 'XXX', 888, 'PREFERED', 'OLD', 0 FROM DUAL UNION ALL
    SELECT 7, 'XXX', 888, 'PREFERED', 'NTB', 1 FROM DUAL )
    SELECT T1.*, CASE WHEN MOD(ROW_NUMBER() OVER (PARTITION BY customer_no, card_type  ORDER BY SEQ_NO),2)=1 AND CARD_TYPE = 'PREFERED'
             AND NTB_Cust='NTB' THEN 1 ELSE 0 END PAID_FLG_FROM_SQL
    FROM   T1
    ORDER BY SEQ_NO;
    

    * 009 *.

  • I received the following updates several times and they always fail to install, they are KB949074, KB2656353 and KB2656370. How can I fix it?

    Receive automatic updates and there are three that will not be installed?   They are KB949074, KB2656353 and KB2656370.   I needs Blons them or should I solve the problem?

    Hi sgmillersr,

    ·         Did you do changes on the computer before the show?

    ·         You are able to install other updates successfully?

    ·         You get the error message?

    Follow these methods.

    Method 1: Temporarily disable the security software.

    Note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you do not disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network during the time that your antivirus software is disabled, your computer is vulnerable to attacks.

    Method 2: Put the computer in a clean boot state to see if there is a software conflict as the clean boot helps eliminate software conflicts.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Note: After completing the steps in the clean boot troubleshooting, follow the section How to configure Windows to use a Normal startup state of the link to return the computer to a Normal startupmode.

    After the clean boot used to resolve the problem, you can follow these steps to configure Windows XP to start normally.

    (a) click Start, run.

    (b) type msconfigand click OK.

    (c) the System Configuration Utility dialog box appears.

    (d) click the general tab, click Normal startup - load all services and device drivers and then click OK.

    (e) when you are prompted, click on restart to restart the computer.

    Method 3: You can also manually install updates (KB number) by downloading from the Microsoft Download Center.

    http://www.Microsoft.com/downloads/en/default.aspx

    Method 4: Follow the steps in the article.

    How to reset the Windows Update components?

    http://support.Microsoft.com/kb/971058

    You cannot install some programs or updates

    http://support.Microsoft.com/kb/822798

  • How to write the query

    Hello

    How to write the sql query

    I have three type of table as

    1 table emp

    EMP_ID FIRST_NAME DEPT_ID

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

    1 kumar 10

    2 sam                          20

    3 30 damu

    2 table dept

    EMP_ID SALE_ID DEPT_ID

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

    1 101 10

    2 102 20

    3 103 30

    3. table sale

    EMP_ID SALE_ID SALE_AMT

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

    1 101 7

    2 102 8

    3 103 9

    I want the result as

    EMP_ID DEPT_ID SALE_AMT

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

    1                10                  7

    Thank you

    Are you looking for this?

    SELECT T1. EMP_ID,

    T1. DEPT_ID,

    W3M SALE_AMT

    FROM EMP T1,

    SALE T3

    WHERE T1. EMP_ID = T3. EMP_ID;

    OUTPUT:

    EMP_ID DEPT_ID SALE_AMT

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

    1         10          7

    2         20          8

    3         30          9

    If this is not the case, after the actual output, you need. Because that gives you the amount of sales deptwise

  • How to write the query option in expdp

    Hi Please someone help me how to write the query option in expdp... .in expdp using the query option...

    where AM columnname between 5 May 12 02:57:00.000' and ' 02:59:59.999 6 May 12: ';


    Please do what is necessary...

    Pavan Kumar says:
    QUERY = (columnname scott.test: "where between 5 May 12 02:57:00.000 h ' and ' 6 May 12 AM 02:59:59.999'")

    Who will fail in databases, because you assume nls_date_format. How it is difficult to put to_date() surround channels? Rather than play with quotation marks, using one parfile thusly.

    query=table_owner.table_1:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    query=table_owner.table_2:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    query=table_owner.table_3:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    

    You do not have to have all the clauses in a single line, as they are side by side parfile, which would be enough. For this reason parfile is better than the command line in order to avoid all the back-citing dance.

  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • How to write the select query for it

    Hello

    I had an html form and the area I drop down and he needs to select several values in the drop-down box. When I select multiple values then I have to write the query to SQL select statement.

    When I try to write the select statement and trying to run I get the error message.

    Select * from Table

    where emo_no = '1,2,3 '.

    That's how I write the query please suggest me how to write the query to select several values in the drop-down box.

    Thank you

    Use the keyword sql 'in '.  If you don't know how, I've heard good things about the book Teach Yourself SQL in 10 Minutes by Ben Forta.

  • How to find the last update date, time and user of the file field peoplecode

    How to find the last updated date time fields of peoplecode records?

    Thank you.

    We can check the update date-time using the following query

    SELECT LASTUPDDTTM IN THE PSPCMPROG WHERE OBJECTVALUE1 LIKE "RECNAME" AND OBJECTVALUE2 AS "FIELDNAME".

  • How to stop the Firefox update page to load whenever I run the FF 3.6.16 application

    How to stop the Firefox update page to load whenever I run the application FF 3.6.16. I use it on an iMac G5 ALS.

    See the following for a few suggestions:

  • The following updates have not been installed: the 2007 Microsoft Office Suite Service Pack 2 (SP2) _ - Error Code: 0 x 80070663

    I resolved all errors related to locate. MSP files during installation - resolution = drive C search for *.msp and pointing the browser to the specified files.

    Now that I'm getting "the following updates were not installed: the 2007 Microsoft Office Suite Service Pack 2 (SP2)" several times and the error code is '0 x 80070663 '.

    How can I fix this error?

    I suspect that there is something wrong in your registry. Hope that you have not used a registry cleaner.

    Have you tried to repair/reinstall Office 2007 (have your handy product key).

    See also for reference: http://support.microsoft.com/kb/946691
    He mentions SP1 but apply to SP2

    TaurArian [MVP] 2005-2010 - Update Services

  • any ideas? Installation failure: Windows failed to install the following update with error 0 x 80070663: update of security for Microsoft Office System 2007 (KB972581). That's what I get away

    Installation failure: Windows failed to install the following update with error 0 x 80070663: update of security for Microsoft Office System 2007 (KB972581).


    any ideas?

    Suggestion: Try to do a repair of Office 2007 installation, then try the updates (after a reboot).

    How to install and repair 2007 Office features
    http://support.Microsoft.com/kb/924611 TaurArian [MVP] 2005-2010 - Update Services

  • The following update; A security update for Microsoft XML Core Services 4.0 Service Pack 2 for x 64 systems (KB954430).

    The following update; A security update for Microsoft XML Core Services 4.0 Service Pack 2 for x 64 systems (KB954430).  How to fix this?

    Hi qaqcno1,

    Please take a look at the following Microsoft KB article:

    KB 910339: How to troubleshoot Windows Update or Microsoft Update when you are repeatedly offered an update

     

    We can't wait to hear back from you on your results.

    Brian
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Cannot install the following updates: KB2707511, KB2676562 and KB2393802.

    Original title: does KB2707511, KB2676562 and KB2393802

    Automatic update of Windows try and does not apply KB2707511, KB2676562 and KB2393802 to my Windows XP PC whenever I stop. If I apply in Windows Update, it is said that they are installed successfully, but they are not. They show whenever I ask Windows Update updates are available, and as I said earlier, the auto update feature still trying and he is unable to apply them on reboots.

    Do I need these updates?

    If so, how can I actually apply?

    Hello

    1. What is the exact error message you get?

    2 have had any changes made to your computer before this problem?

    Perform the following methods and check:

    Method 1: Run the patch from the following link and check:

    http://support.Microsoft.com/mats/windows_update

    Method 2: Clean boot the computer and then try to install the updates.

    See the following article to put the computer in a clean boot state:

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Note: Make sure that you put the computer to a Normal startup once you are finished.

    Method 3:

    Check if the reset Windows Update components allow you to install the updates of Windows.

    How to reset the Windows Update components?
    http://support.Microsoft.com/kb/971058

    Let us know if it helps.

  • The following updates 5 will be "installed successfully" but reappear on loans for the installation of all the days of updates: kb2600217, kb2533525, Ko 2468871, KB2656351, KB87367.

    Hey all,.

    The following updates 5 will be "installed successfully" but reappear on loans for the installation of all the days of updates: KB2600217, KB2533525, KB2468871, KB2656351 and KB87367. Any advice on how to fix this?

    TIP: See the first, 4 specific sub-section of .NET Framework of the method of resolution 2 (only!) on this page-online http://support.microsoft.com/kb/976982

  • Open XML, how to write the path

    Hello

    I'm new to the Blackberry development and I hope you can help me with my problem. I try to work with an XML file, and so far, all that does very well as long I had the xml file, I work on, in the folder of my java application and deyployed using the desktop software. Now, I tried to put the file somewhere else on the Blackberry and I don't know how wirte the path to the source code. I tried the following, but it seems to be bad:

    private static String _xmlFileName = "file:///store/home/user/documents/test.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                InputStream inputStream = getClass().getResourceAsStream( _xmlFileName );
                Document document = builder.parse( inputStream );
    

    I hope you can give me a hint, how I write the correct path?

    Thank you very much!

    Best regards, jtr87

    PS: Sorry for my bad English, but I did not use it very often.

    You need to do something like that to get your InputStream:

    /** * @return an open InputStream for a file, or null if file does not * exist. * @throws IOException if there is an error opening the file */InputStream getInputStream(String name) throws IOException {
        FileConnection fc = null;
        try {
            fc = (FileConnection) Connector.open(name, Connector.READ);
            if (fc.exists()) {
                return fc.openInputStream();
            }
        } finally {
            if (fc != null) {
                try {
                    fc.close();
                } catch (Exception ignored) {
                }
            }
        }
        return null;
    }
    

    Notice that you must close the FileConnection at some point, regardless of if the call to openInputStream worked.

Maybe you are looking for

  • Type in the URL does not work

    On my Samsung SIII, after updating FireFox 14.0, I can't enter the URL OR text search bar "Search Enter or address. If I type a search term and Google search (for example), and then select the indicator 'Enter search or address' remains in the bar, t

  • not found in the system

    Hi there ive tried to download manager HP recovery but said the softpaq will not be installed because HP Recovery Manager cannot be found in my system? What to do now? Lisa x

  • How can you correct 0x8dddooo4 error message

    How can you correct 0x8dddooo4 error message

  • Volume bar that appears on the screen when the volume control has disappeared.

    I recently had to create a new profile on my computer because my old profile somehow corrupting.  In my old profile, I got a small box of volume that would leap whenever I set the volume with the buttons on my keyboard and would let me know how high

  • WORKS for windows 7

    I have office 2010 and it's too much for me to understand.  How can I return to Microsoft Works?  I see it on sale on the internet, but not from Microsoft. I have a new computer with windows 7, line 9.  I acually have a my original disc Works 4.5 t -