How to number the presence of data in a table

I have a table with data as below:

Column1 Column2
pk_1one
pk_2one
pk_3b
pk_4b
pk_5b

I want the number of occurrence of Column2

I have wnt the result as below:

column 1 column 2 column 3

pk_1

one1
pk_2one2
pk_3b1
pk_4b2
pk_5b3

Please suggest a query to get the result.

Hi Tony,.

Use the analytical functions.

Something like that?

WITH t (col_1, col_2, col_3))

SELECT "pk_1', 'a', NULL FROM dual UNION ALL

SELECT 'pk_2', 'a', NULL FROM dual UNION ALL

SELECT 'pk_3', 'b', NULL FROM dual UNION ALL

SELECT 'pk_4', 'b', NULL FROM dual UNION ALL

SELECT 'pk_5', 'b', double NULL

)

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

-Samples above

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

SELECT col_1, col_2,

ROW_NUMBER() OVER (ORDER BY col_1 col_2 partition) col_3

T;

COL_1, COL_2 COL_3
-------- -------- -----
pk_1 has 1
pk_2 has 2
pk_3 b 1
pk_4 b 2
pk_5 3 b

I think that the RANK function can also be useful.

Tags: Database

Similar Questions

  • does anyone know how to number the photos when they are exported so someone can choose the peak of number

    Anyone know how to number the photos when they are exported from LR, so someone can choose the photo they like with a number

    Sorry took with the last answer.

    More simple form used something like-Sequence_Filename number suffix

    If an image as _ABC0987.nef will become 0001_0987.nef and 0002_0988.nef, etc.

    Ask your customer to give you the full file name. The suffix indicates the original file.

    (I hope that you only need to search in a folder and do not have a bunch of images named the same that would cause problems!)

  • How to fix the error "insufficient data" in Acrobat Reader 11.0.04?

    How to fix the error "insufficient data" for Acrobat Reader 11.0.04?

    Hi Johnkel1524,

    Please visit: http://helpx.adobe.com/acrobat/kb/insufficient-data-image.html

    Also, try to update on 11.0.5 and check.

  • 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 change the PCTFREE parameter for an existing table

    How to change the PCTFREE parameter for an existing table?

    Guys can you help me please

    Hello

    Of course it is possible.
    In this case you would export the table from the database (using old style exp)
    Start the import with the index_file option to generate the table/index instructions
    Modify the file created and updated the PCTFREE and remove any that need to be performed (default, if I remember correctly, he comments on the statements of the Index)
    Run the file for the table and the index created
    After that start the import with the option "ignore = yes".

    Make sure that you export only this particular table using "tables =
    Also in importing the "ignore = yes" will also be important data that still exists.

    In my view, however, this is not what you want to do. It's more complex, sensitive failure and the table should be deleted, so users are affected unnecessarily long.

    Success!
    FJFranken

  • How many number clues can be made in a table?

    How many number clues can be made in a table?

    Hello

    user12059276 wrote:
    How many number clues can be made in a table?

    Any number. There is no limit.

  • How to implement the reading of data from a matte file on a cRIO?

    Hi all!

    I'm still not sure, it is plausible, but I'll ask rather before you begin complicating. So far, I found no useful information on reading in the data to a device of RT from a file (type of a simulation test - data is simulated).

    I have the MatLab plugin that allows the storage of data read a MAT file, which has a number of columns that represent the different signals and lines representing the samples at a time (depending on the time of the sample - sample every time has its own line of signal data).

    I have no idea how to implement this at cRIO.

    The idea is:

    I have some algorithms running on the controller of RIO in a timed loop. As the entries of these algorithms I need to access each of the values of columns in the row, which is the time of the sample (sort of a time series - without written actual times).

    I am fairly new to RT and LV development, so any help would be appreciated.

    Thank you

    Luka

    Dear Luka!

    I think the reading of all the samples in a single channel is exactly what you need here, because reading the files may take some time and is not deterministic, so it is best to read all the data in memory (or if this is not feasible due to problems of size, fairly large pieces may be sufficient). The table read can be provided and then in the loop simulating outings, something like this:

    I used here separate channels so it's more graphic, but you can build all the channels in a 2D array and array index corresponding to the samples fom 1 who. You can also use for loops with indexing as tunnels are setup and then you won't need the index functions and the number of iterations is also set automatically, but you have to take care of synchronization settings.

    Best regards:

    Andrew Valko

    National Instruments

  • How to get the timestamp of data DAQmx Read

    Hello

    I have to read 4 analog channels using DAQmx AI read in LabVIEW 2012. I am using screws DAQmx.

    Acquisition rate is 4000 samples per second, and the number of samples per channel is 200.

    I use only one task DAQmx to read the data. I get 4 data tables for 4 channels each table length is 200, every time, DAQmx Read happens.

    But I want to get the seal of these 200 samples per channel. How to get the seal of these samples, made me know.

    Thank you

    You have not indicated your code. If you choose to read the waveform data, the cluster includes t0 and dt. That's all the information you need.

  • How to access the Non-space data of the object using the API of the HTML5

    Using the Oracle cards HTML5 API, is it possible to access the data an excerpt when generating a map?

    For example, my database has a table named ITEMS:

    Table: ELEMENTS

    COL_A

    COL_B

    COL_C

    COL_D

    COL_E

    COL_F

    GEOMETRY

    This table contains a number of objects point.  With the help of Mapviewer, I can successfully create a map by using the HTML5 API.  Here is an example of how I used the constructor 'OM.layer.VectorLayer.TYPE_JDBC' to retrieve the objects point of my database.

    pointLayer = new OM.layer.VectorLayer ("PointLayer",

    {

    infoWindow: true,

    def:

    {

    type: OM.layer.VectorLayer.TYPE_JDBC,.

    dataSource: "myDatabase",.

    SQL: "SELECT * FROM POINT."

    geometryColumn: "GEOMETRY."

    labelColumn: "COL_A."

    loadOnDemand: false,

    URL: baseURL

    },

    renderingStyle: circleMarker

    });

    How can I use the HTML5 API to access the data in the other columns (COL_A, COL_B, etc.) of my table?

    I know that the methods DisplayInfoWindow() and displayTabbedInfoWindow of the Map class to view this information by clicking on a specific point on the map.  But I would like to have access to all the points to create a table below my map showing all points (and their data) shown on the map.

    Hello

    You can try this code:

    functions var = pointLayer.getAllFeatures ();

    for (var i = 0; i)

    {

    Features [i]. GetAttributes() ["COL_A"];

    Features [i]. GetAttributes() ["COL_B"];

    ......

    }

  • How to get the difference in dates in days

    Hi friends,

    How to get the date difference between two dates exactly

    date2-date1 days exactly... shouyld rounded to the nearest value of...

    and one entire display i mean positive integer
    Select round ((sysdate) - to_date (date_start)), date_start days of per_periods_of_service

    This gives negative also result

    Hello

    776317 wrote:
    Hi friends,

    How to get the date difference between two dates exactly

    date2-date1 days exactly... shouyld rounded to the nearest value of...

    Date1 - date2 is the exact number of days is after date2 date1. (It is as accurate as possible, given that the DATEs do not have fractions of a second).

    and one entire display i mean positive integer
    Select round ((sysdate) - to_date (date_start)), date_start days of per_periods_of_service

    You want to probably get the exact number of days first, then ROUND this number:

    SELECT  ROUND (SYSDATE - TO_DATE (date_start, ...))   AS days
    FROM    per_periods_of_service; 
    

    Always pass arguments at least 2 to TO_DATE:
    (1) the string to be converted, and
    (2) a saying string how (1) is formatted

    This gives negative also result

    Right; If date1 is before date2 then date1 - date2 returns a negative number.
    If you want to never get a negative value, use ABS (date2 - date1). If it returns 4, then you know that one of the DATEs was 4 days before the other, but you won't know who was earlier.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • How to make the exchange of data between 2 whole loop real-time

    Hello
    I have 2 while loop
    the 1st loop includes data acquisition program
    the 2nd loop includes control program
    --------------------------------------------------------------------------------------------------------------
    My question is how do the exchange of data between 2 whole loop real-time

    --------------------------------------------------------------------------------------------------------------
    I tried with the variable and direct wiring between the 2 local while loop
    It does not work (there is a delay)


  • How to set the time and date on printer n911a e-all-in-one officejet pro 8600.

    How do you set the time and date on printer n911a e-all-in-one officejet pro 8600. This info is not in the user's guide or the getting started guide.    Thanks in advance. Jim

    Jim go to settings on the 8600, click Preferences.

    There is an option DATE and HOUR.

  • How to extract the response JSON data

    Hi all

    I get the following response from the server.

    "
    "PAO - ENV ="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ns1 =" urn: soapservice "container ="http://www.w3.org/2001/XMLSchema"xmlns: xsi ="http://www.w3.org/2001/XMLS
    "Chema-instance" xmlnsPAO - ENC = "http://schemas.xmlsoap.org/soap/encoding/" SOAP - ENV:encodingStyle ="http://schemas.xmlsoap.org/soap/encoding/" > ""<>
    tAdvertismentReturn xsi: type = "xsd: String" > {'MSG1': '1', "MSG2": "success", "DA..."}

    Now, I want to create a QVariantList using JsonDataAccess.

    If I manually extract the JSON string after that

    downloadData = jda.loadFromBuffer (data);

    so I'm able to get the data.

    Without extraction like that how can I take the response JSON data?

    Thank you.

    Thanks for your time,

    Here's my problem how to build a soap with the response object.

    I solved this problem with the help of the example of the weather.

    Thank you.

  • How to change the time and date on the desktop?

    My computer does not show the time and date.

    I tried several times to update the date and time, but after the judgment the same problem persists.
    How to solve the problem?

    Mr. Thanapackiam I know that this issue please follow my steps

    Step 1:-go to the Start Menu and Type "region and language" and press enter
    Step 2:-go to the location tab and select your current location
    Step 3:-go to the Start Menu and Type "Services" and press ENTER. (i.e. open Services)
    Make sure that the Windows time service is running.
    Step 4:-click Date and time on the far right of the taskbar.                           Click Change Date and time settings.
    Step 5:-click Change Date and time settings button to change the date and time
    Step 6:-Click Internet Time to synchronize the time with the Server online
    Step 7:-   click on change settings , then update now

    Thank you
  • How to search the dictionary of data for the partitions of the interval?

    Oracle 11.2.0.3

    When I have a DBA_PART_TABLES request. PARTITIONING_TYPE he says "beach". I want to be able to differential an interval of other partitions of range based in the data dictionary?


    used this example. Watch "range".

    http://www.rittmanmead.com/2008/09/investigating-Oracle-11g-interval-partitioning/

    Oracle Docs list 'SYSTEM' as a partitioning_type that I thought would be intervals.

    ALL_PART_TABLES

    [code]

    1 CREATE TABLE interval_sales

    2 (prod_id NUMBER (6))

    3, cust_id NUMBER

    4, time_id DATE

    5, channel_id char (1)

    6, promo_id NUMBER (6)

    7, quantity_sold NUMBER (3)

    8, amount_sold NUMBER (10.2)

    9          )

    10 PARTITION BY RANGE (time_id)

    INTERVAL OF 11 (NUMTOYMINTERVAL (1, 'MONTH'))

    12 (PARTITION p0 VALUES LESS THAN (TO_DATE (' 01/01/2005 ',' DD-MM-YYYY "")),)

    13 PARTITION p1 VALUES LESS THAN (TO_DATE (' 01/01/2006 ',' DD-MM-YYYY ""));

    14 p2 PARTITION VALUES LESS THAN (TO_DATE (' 07/01/2006 ',' DD-MM-YYYY ""));

    15 * PARTITION p3 VALUES LESS THAN (TO_DATE (' 01/01/2007 ',' DD-MM-YYYY "")))

    SQL > /.

    Table created.

    Elapsed time: 00:00:00.01

    SQL > select partitioning_type from the user_part_tables where table_name = 'INTERVAL_SALES ';

    PARTITION

    ---------

    RANGE

    [/ code]

    CREATE TABLE junk1
       ( id         NUMBER )
       PARTITION BY RANGE (id)
       INTERVAL(5)
         ( PARTITION p0 VALUES LESS THAN (5),
           PARTITION p1 VALUES LESS THAN (10),
           PARTITION p2 VALUES LESS THAN (15),
           PARTITION p3 VALUES LESS THAN (20) )
    /
    
    CREATE TABLE junk2
       ( id         NUMBER )
       PARTITION BY RANGE (id)
         ( PARTITION p0 VALUES LESS THAN (5),
           PARTITION p1 VALUES LESS THAN (10),
           PARTITION p2 VALUES LESS THAN (15),
           PARTITION p3 VALUES LESS THAN (20) )
    /
    
    select owner, table_name, partitioning_type, interval
      from dba_part_tables
     where table_name in ('JUNK1', 'JUNK2')
    /
    

    TABLE_NAME OWNER PARTITIONING_TYPE INTERVAL

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

    GREGS                          JUNK1                          RANGE             5

    GREGS JUNK2 RANGE

    2 selected lines.

Maybe you are looking for

  • Satellite L450 - 16K micro BUG

    Hi all! I have a Satellite L450 - 16K with a bug of microphone here.When the microphone is pumped 30 dB, it will so loud beep.I don't know why, but without stimulation, just on the maximum volume, it works normally.I tried the realtek driver, but the

  • Deletes the file datalog

    I did experiment with the Panel before auto logging feature, I have no bad to save data to a file in a vi and recover, BUT I can't seem to be able to delete the log file of the top-level vi.  I get the message file that is already open, but I don't s

  • EliteBook 850: Unknown device

    Hello I have an 'unknown device' showing in my device manager. AFAIK this is the laptop says its location is "Port_ #0005.Hub_ #0005. I had it's new and I have never been able to download anything on Windows Store. I think that the unknown device may

  • "80244018" Windows update error!

    Hey,. Whenever I try to install the updates through Windows Update, it gives me the following error message: "Code 80244018 windows update encountered an unknown error. How should I do?

  • Setting a QML property in another file

    I'm pretty new to stunts, so I hope someone could help me with this. This piece of code is supposed to load main.qml, with a button to open a separate sheet (CountryList.qml). On this sheet, it loads a local XML database in a ListView. The user selec