Auto number similar  data

I have a request to create a query that will number items that have similar data in fields.
For instance data like this
OwnerName Location Item
John NY CAR
John NY Truck
John NY VAN
Bill Ca Truck
Bill CA Car
Bill CA VAN
Joe IL Bike
Joe IL RV
Joe IL Truck
They want this data to be spit out like the below example appending the location with a number for each group like this
OwnerName Location Item
John NY -001 CAR
John NY -002 Truck
John NY -003 VAN
Bill Ca -001 Truck
Bill CA -002 Car
Bill CA -003 VAN
Joe IL -001 Bike
Joe IL -002 RV
Joe IL -003 Truck
I am at a loss out exactly how to do this, Using Oracle 10g. I thought maybe a temp table or something but not real sure.
I am more of a MS Sql Server guy.
Any ideas much appreciated thanks!!!

Hi,
This sounds like a job for the analytic ROW_NUMBER function:
SELECT     ownername
,     location || '-'
           || TO_CHAR ( ROW_NUMBER () OVER ( PARTITION BY  ownername, UPPER (location)
                                 ORDER BY      item
                   , 'FM000'
                   )     AS location_plus
,     item
FROM     table_x
gtjr wrote:I have a request to create a query that will number items that have similar data in fields. Which fields? It's unlcear whether you want a separate set of numbers (1, 2, 3, ...) for each ownername, or each loaction, or each distinct comination of ownername and location. I assumed that it was for each combination of ownername and location (case insenitive, so 'Ca' and 'CA' in your sample data are considered the same), so that if you added a row with onwername='Joe' and location='NY', it would be numbered 1, not 4. If I guessed wrong, just change the analytic PARTITION BY clause.
John NY -001 CAR
John NY -002 Truck
John NY -003 VAN
Bill Ca -001 Truck
Bill CA -002 Car
Bill CA -003 VAN ...It's also unclear in what order you want the numbers assigned. I don';t understand why you want the 'CAR' in 'NY' to be number 1, and the 'Truck' to be 2, but just the opposite in 'CA'. The query above will assign them in order by item: a 'Car' will always be numbered lower than a 'Truck', and a 'Truck' will alwyas be lower than a 'Van' for the same ownername and location. Whatever order you want, change the analytic ORDER BY clause accordingly. You must have an analytic ORDER BY clause, however, even if it's only ORDER BY NULL.
I am at a loss out exactly how to do this, Using Oracle 10g. I thought maybe a temp table or something but not real sure.
I am more of a MS Sql Server guy. In Oracle, temporary tables are almost never the right way to do anything.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
Explain how you get those results from that data.

Similar Messages

  • Auto number as a data type?

    Hello,
    Is it possible in Oracle to use an auto number (integer) to automatically give a number for a column such as ID whenever a record is created or inserted? This would be similar to MS Access.
    TIA.

    There has been some debate (both within NI and with customers) about whether or not the flattening/unflattening solution is actually desirable. After all, if NI made the shared variable support classes, to do the writing to the variable, the object would be flattened to a string and then unflattened when the variable is read. In other words, having the shared variable support classes does not actually remove any work that the program has to do, so having the shared variable do this behind the scenes is just syntactic sugar. The negatives crop up with the issues that Phillip raised -- suddenly the shared varible is reporting a number of errors that it did not support previously, whereas by separating the (un)flattening into a separate node, it is easier to tell where an error is arising -- was it a failure to read a shared variable or was it a failure to unflatten the data therein? By keeping the shared variable ignorant of such complex data types, it is easier to swap out the communication mechanism used -- shared variables might get support for LV classes, but TCP/IP prims might not, or whatever other communication protocol comes along in the future (i.e., the network stream primitives that are brand new in LabVIEW 2010 -- effectively queues that are usable over the network).
    Users may choose to create a custom string format for objects, one that can be unflattened by any system that uses the shared variable -- including CVI and MeasStudio. Having shared variables support classes directly does not get in the way of this, but consideration of exactly what private fields actually need to be exposed in that very global global variable might be encouraged if users are consciously aware of the serialization taking place.
    I'm not pro or con this feature at this point... this post is merely to document debate I've heard about any intermachine communications protocol handling LV classes directly.

  • Auto Date field and Auto Number field

    I am fairly new to this,
    I have crated a form using the form wizard in Acrobat Pro 9.0 and I would like to make a field an Auto date field and another an Auto Numbering field. I have read a lot of the posts and there are a lot of recommendation to point the auto number to a database. This is fine but I do not know how to reference that field to an external database. PLEASE HELP!!!! Somebody GEEK me!!

    I am fairly new to this,
    I have crated a form using the form wizard in Acrobat Pro 9.0 and I would like to make a field an Auto date field and another an Auto Numbering field. I have read a lot of the posts and there are a lot of recommendation to point the auto number to a database. This is fine but I do not know how to reference that field to an external database. PLEASE HELP!!!! Somebody GEEK me!!

  • URGENT:  Is it possible to auto-number superscripts?

    Context: I am trying to put my qualitative data into some sort of order so it is easy to locate quoted text. I have decided to use a numbering similar to what is used in religious books (ex., Bible). I use a superscript at the beginning of each sentence within a specific section.
    Question: Is it possible to auto-number text using superscripts?
    Concern: My concern is that as I do this by hand, I am bound to miss the beginning of a sentence and then every sentence thereafter will have to be renumbered. (Of course, the reality is that I most likely will not do that but just give the number a letter after it.)

    Hi Jay,
    You can use the Item Id field of the SharePoint list which will get incremented by 1 whenever you add the new item.
    you can refer the below threads for other options of auto increment id
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/134fd5f6-17ce-4044-a78e-e7a32b523190/creating-autoincrement-field-in-sharepoint-list?forum=sharepointgeneralprevious
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/39743bb3-872d-4788-96a8-2b9fb8813011/create-auto-increment-value-in-sharepoint-column?forum=sharepointgeneralprevious
    My Blog- http://www.sharepoint-journey.com| Twitter
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful

  • Questions on Merging Dis-similar Data Types...

    I am using Web-I version 11.5.8.834 (We do not use the Crystal Reports module, all of our reports are built with Web-I).
    I have two questions:
    Question 1: First I am attempting to create a report from two different universes and need to merge a dimension from each universe.  The two dimensions have similar data, but one is set up as a "string", and the other universe has the same data set up as a "number".  Our IT department creates and maintains the universes and I have requested that one of the dimension data type be changed to match the other, but I am told that other users have already set up reports using these dimensions and to change them at this point might cause a problem with their reports.  So my first question is: Can two separate dimensions be setup within a single universe, using the same data field, each having different data types (e.g., a field with numeric data be set up as a "string" and a second dimension be setup as a "number")?  If this works, I can make a recommendation to our IT department to do this and I will not have to resort to Question 2.  but just in case, here is Question 2:
    Question 2: I have two other dimensions that I might be able to use, but it requires creating a variable and "trimming" data off of each of the fields.  The first universe is a part number with three alpha characters followed by four numeric characters (PRT1234).  The second universe has a serial number, in which the first four characters match the last four characters of the other universe (1234-00111).  If I trim off the first three characters from the first universe using a variable (=right([Part_Number];4), and trim off the last six characters from the second universe using a variable (=left([Serial_Number],4), the variables will have matching data.  The second question is: Can variables be merged?  I've tried, but it isn't working so far.  If so, can someone give me some hints on how to do it?
    Edited by: Charles Norman on Aug 8, 2008 11:42 AM
    Edited by: Charles Norman on Aug 8, 2008 11:43 AM

    Charles,
    Can variables be merged?
    No, local variables cannot be merged.  The manipulation must be performed at the database level via Designer before the data comes across to the report.  As an aside, your IT deparatment can create "new" objects just for you, placed in the list under a separate sub-class that manipulates the data to your liking and will not upset other users who already built reports using the original columns of data.  I guess my point is that you can have multiple objects placed in your universe that derive from the same column in a given table -- user A has it per their flavor and user B has it per his flavor.
    Thanks,
    John

  • Auto-fill/password data deleted following Safari crash

    So, I've been having a seriously large amount of problems with Safari crashing over the past few months. Usually it just shows the spinning wheel of death, sometimes it just automatically reloads every page/tab I have open (if anyone can suggest a fix for that it would be great).
    However, this time it crashed and it appears to have completely wiped out all of my auto-fill/password data that I had saved. As this is a personal computer and nobody else uses it, I had a lot of passwords saved into it (most of them for low security risk sites). As everybody knows, a user often has hundreds of usernames/paswords for a huge number of websites. I can't remember them!
    I'm concluding that as they've all been deleted, I'm going to have to go through the arduous process of clicking the 'forgotten username/password' to retrieve these details; however, now whenever I try to save back in the auto-fill, it's not really working too well and just isn't saving it, despite me choosing for auto-fill to be operational on the website.
    Any help would be massively appreciated to sort this, as having to keep entering my usernames/passwords - urgh, let's just say this is the biggest first world problem since before bread was sliced!!
    Safari version 5.1.10
    Mac OS X Version 10.6.8

    Passwords are stored in Keychain Access located in Applications > Utlities
    Launch Keychain Access then select Passwords on the left.
    Type in the name of a website you've visited that autofilled the password.
    Then double click the website name the select the Attributes tab then click: Show password
    You may be prompted for your admin password to proceed.
    If you want a website to re remember the password, right or control click the website name in Keychain Access the click Delete.
    The next time you login to that site and enter your password you should be prompted to save that data to a new keychain.
    message edited by:  CS

  • Number to Date conversion

    Hi, in my answers report date is displaying as 20,071,224.0 , i want to convert this number to Date format like MM-DD-YYYY, this is not a Time Dimension. do we need to convert this column in RPD or can we do it from Answers, Please help me on this.
    OBIEE 10.1.3.4.1

    i tried using to the below similar query but getting the following error
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 12801, message: ORA-12801: error signaled in parallel query server P041, instance omidrl020:DOBI1 (1) ORA-01861: literal does not match format string at OCI call OCIStmtExecute
    [nQSError: 10058] A general error has occurred. [nQSError: 22025] Function Cast is called with an incompatible type. (HY000)
    SQL Issued: SELECT "PT"."PT Description", "PT"."QTD Pay Item Amount", "PT"."YTD Pay Item Amount", "PT".PAY_ITEM_AMT, "PT".PAY_DT_WID, "PT".PAY_DT_WID, "Teammate Attributes"."Teammate Name", "Teammate Attributes"."Teammate Number", CAST("PT".PAY_DT_WID AS DATE) || '-' || CAST("PT".PAY_DT_WID AS DATE) || '-' || CAST("PT".PAY_DT_WID AS DATE), Time."Month", Time."Year" FROM
    PAY_DT_WID column type is DOUBLE in rpd, which is the type we need to use with the CAST function, Please help me

  • Number to date

    Hi Experts, I have a DATE_WID column as Number(10). I want to convert this to Date format in MM/DD/YYYY in BMM layer. How can I do that?
    thx,
    parag

    Hi parag,
    Check this similar post Plane number to Date conversion in obiee
    hope helped you.
    Cheers,
    KK

  • Auto number by sequence and trigger - issue

    Hi,
    i need to insert auto number in one of the column of my table, and i tried like the following way..
    CREATE TABLE STOP_TRACKING
      ID                    NUMBER                           primary key,
      MSISDN                NUMBER                  NOT NULL,
      TIME_STAMP            DATE                    DEFAULT SYSDATE,
      STOP_TRACKING_RESULT  NUMBER,
      REQUEST_ID            VARCHAR2(60 BYTE)
    TABLESPACE SYSTEM
    PCTUSED    40
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
                BUFFER_POOL      DEFAULT
    LOGGING
    NOCACHE
    NOPARALLEL;
    COMMENT ON COLUMN STOP_TRACKING.STOP_TRACKING_RESULT IS 'IF RESULT ID "0" - OK AND IF RESULT ID "1" - NOT OK';
    create sequence seq_autonumber;
    CREATE OR REPLACE TRIGGER trg_autonumber
    BEFORE INSERT ON STOP_TRACKING
    FOR EACH ROW
    WHEN (new.id IS NULL)
    BEGIN
      SELECT seq_autonumber.NEXTVAL
      INTO   :new.id
      FROM   STOP_TRACKING;
    END;
    /when i execute the create trigger sql in toad sql editor am getting a pop up saying
    >
    variable name:NEW
    Type: drop down list ...here i tried almost relevant data types, int,long,....
    Value:...here i entered 1
    and clicked ok...and got the error as
    ORA-01036: illegal variable name/number
    >
    what could be issue?
    Edited by: Aemunathan on Nov 22, 2009 2:55 PM

    I just copy pasted your code.
    Works just fine.
    I believe you issue is realed to TOAD rather than pl/sql.
    Would have loved to help you but i use pl/sql developer.
    However if possible send a screen shot.
    Cheers!!!
    Bhushan

  • The key columns of the country measure group attribute do not match in either number or data types to the key columns of the source attribute

    I have a country dimension which is used in 5 cubes. Now I want to change 'key column' property of the country attribute. Whenever I do this, I get an error as "The key columns of the country measure group attribute do not match in either number or
    data types to the key columns of the source attribute". I dont understand what this error is about.
    Can someone please help? Thanks in advance.
    -Regards,
    Raj Patil

    sounds like you need to verify your dimensional usage tab to verify the relationships between dim and fact on the measure group. 
    Hi Talktorajpatil,
    As Jon said, you can verify the relationships between dim and fact on the measure group on the dimensional usage tab. Use this section to define how you "join" your measure groups to your dimensions.  There may be a Dimension-Measure Group relationship
    that is defined using the wrong attributes and you'll need to select the correct attributes to link the Dimensions to the measure groups. Here are some similar thread for your reference.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/74203b66-8a71-4681-8e47-8f99cce87b3d/error-on-the-measure-group-which-do-not-match-the-data-type-of-the-key-column?forum=sqlanalysisservices
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2421058d-fd4a-44b8-8c7c-b0b349bbef2d/measure-group-attribute-key-column-does-not-match-source-attribute?forum=sqlanalysisservices
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Auto number each form when distributing by email

    I need to assign a number to each form during or before emailing, anyway to do that with scripting? Thanks for all the help, I am getting so close to having everything I need for this form.
    Thanks
    Mike

    Hi Mike,
    I have used the following technique to auto-number a form:
    1) Create a hidden field and use a FormCalc function to get the date-time when the form is opened
    // form1.purchaseOrder.header.DateTimeField1::initialize - (FormCalc, client)
    // The hidden field DateTimeField1 is used as the source for the P.O. number.
    // The function, below, returns a string in the format 20081107055344 where 20081107 is YYYYMMDD and 055344 is HHMMSS.
    $.rawValue = Concat(Num2Date(Date(), "YYYYMMDD"), Num2Time(Time(), "HHMMSS"));
    2) On the target id field extract the month, day, and time (down to the millisecond)
    // form1.purchaseOrder.header.poNum::calculate - (JavaScript, client)
    // DateTimeField1 is used to generate a unique P.O. number (see the initialize event on DateTimeField1).
    // DateTimeField1 produces a value in the format 20081107055344, for example. In this example the substring
    // removes the year 2008 to produce the P.O. number 1107055344.
    var str = form1.purchaseOrder.header.DateTimeField1.rawValue;
    this.rawValue = str.substring(4,18);
    There are many techniques including the creation of a random number using the JavaScript math.random() method.
    See https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Math/random
    Steve

  • Stop Numbers form auto-formatting imported data

    I use a program to track my time, and it exports as a tab-delimited text file. This should be perfect, just import the data into a Numbers table and bada-bing, right?
    Unfortunately, Numbers is taking it upon itself to auto-format the data as it comes in. For example, there are 2 columns in the report that get auto-formatted. The event start column is exported in the form: dd/mm/yyyy hh:mm, and this is handled fine. The duration column is exported in the form: hh:mm, yet is auto formatted as dd/mm/yyyy hh:mm by Numbers.
    Does anyone know a way to stop Numbers from doing this? My only quick workaround is to import the report in Excel first, then open the Excel xsls file in Numbers (and at that point, why bother using Numbers at all?).
    HELP!

    No need to use two applications!
    --[SCRIPT dateTime2duration.app]
    Enregistrer le script en tant que Script, Application ou Progiciel : dateTime2duration.xxx
    déplacer l'application créée dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    Sélectionner les cellules à convertir
    menu Scripts > Numbers > dateTime2duration
    Le script insère les durées correspondantes.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    +++++++
    Save the script as a Script, an Application or an Application Bundle: dateTime2duration.xxx
    Move the newly created application into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Select cells to convert.
    menu Scripts > Numbers > dateTime2durationNumbers
    The script insert the corresponding durations.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    --=====
    Yvan KOENIG (Vallauris FRANCE)
    14 mai 2009
    --=====
    on run
    set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
    set localOffset to (time to GMT)
    tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
    repeat with x from colNum1 to colNum2
    tell column x
    repeat with y from rowNum1 to rowNum2
    try
    set theDate to (value of cell y)
    if class of theDate is date then
    tell (theDate - localOffset)
    set {hh, mm, ss} to {(its hours) as text, its minutes, its seconds}
    end tell
    set value of cell y to hh & "h" & mm & "m" & ss & "s"
    end if -- class…
    end try
    end repeat -- y
    end tell -- column x
    end repeat -- x
    end tell -- Numbers …
    end run
    --=====
    on getSelParams()
    local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
    set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
    if r_Name is missing value then
    if my parleAnglais() then
    error "No selected cells"
    else
    error "Il n'y a pas de cellule sélectionnée !"
    end if
    end if
    set two_Names to my decoupe(r_Name, ":")
    set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
    if item 2 of two_Names = item 1 of two_Names then
    set {row_Num2, col_Num2} to {row_Num1, col_Num1}
    else
    set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
    end if
    return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
    end getSelParams
    --=====
    on decipher(n, d, s, t)
    tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
    end decipher
    --=====
    set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
    on getSelection()
    local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
    tell application "Numbers" to tell document 1
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of tables
    if x > 0 then
    repeat with y from 1 to x
    try
    (selection range of table y) as text
    on error errMsg number errNum
    set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
    return {theDoc, theSheet, theTable, theRange}
    end try
    end repeat -- y
    end if -- x>0
    end tell -- sheet
    end repeat -- i
    end tell -- document
    return {missing value, missing value, missing value, missing value}
    end getSelection
    --=====
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to ""
    return l
    end decoupe
    --=====
    on parleAnglais()
    local z
    try
    tell application "Numbers" to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    --[/SCRIPT]
    Yvan KOENIG (from FRANCE jeudi 14 mai 2009 14:01:29)

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • How to file auto number in save for web ?

    Hi All,
    how to file auto number in save for web ?
    I have make an action script in Photoshop cs5 that
    change the image resolution and SaveForWeb...
    (but at this point user need to supply the file name)
    so, How to write the code/action such that when the
    action button is click the image will save into the file
    file2eMail_001,file2eMail_002,file2eMail_003,file2eMail_004
    or to any unused number ?
    thank for any help!

    You could also ask over in the Photoshop Scripting Forum, I’m pretty certain stuff like progressively numbered copies has been addressed there previously.

  • How to restrict number of Data Records from Source system?

    Hi,
    How can I restrict the number of Data records from R3 source system that are being loaded into BI. For example I have 1000 source data records, but only wish to transfer the first 100. How can I achieve this? Is there some option in the DataSource definition or InfoPackage definition?
    Pls help,
    SD

    Hi SD,
    You can surely restrict the number of records, best and simplest way is, check which characteristics are present in selection screen of InfoPackage and check in R3, which characteristics if given a secection could fetch you the desired number of records. Use it as selection in InfoPackage.
    Regards,
    Pankaj

Maybe you are looking for