Counting with letters instead of numbers

hi everybody,
today I got the requirement to represent the rownums of a recordset (1, 2, 3, 4, 5 and so on) as letters (A, B, C, D, E and so on). First of all I thought there is a database function equal to the to_char function with RN parameter (which is able to convert numbers to roman numbers easily)... but I didn´t find anything.
So, is there a database function that I haven´t found yet or have you got some custom code for me to realize this?
ty in advance
- Oliver

Hi,
I don't think it's quite that simple. OP does not want a base-26 number, because there is nothing quite like a 0 in this system, and therefore nothing quite like a leading 0.
In a base-26 system, you could represent 26 ^2^ distinct numbers with strings up to 2 characters.
OP wants something where you can represent 26 ^2^ + 26 distinct numbers with strings up to 2 characters: 26 numbers with 1-character strings and a completely disjoint set of 26 ^2^ numbers with 2-character strings.
I think OP needs something more complicated, like this:
CREATE OR REPLACE FUNCTION to_abc
(      in_num       IN        PLS_INTEGER               -- Number to be converted
RETURN     VARCHAR2
DETERMINISTIC
IS
     in_num_26     PLS_INTEGER    := MOD (in_num, 26);
     rest          PLS_INTEGER;
     return_txt     VARCHAR2 (30);
BEGIN
     IF  in_num IS NULL
     THEN
          RETURN     NULL;
     ELSIF  in_num <= 0
     THEN
          RETURN  '-';
     END IF;
     return_txt := CHR ( 64 + CASE
                         WHEN  in_num_26 = 0
                         THEN  26
                         ELSE  in_num_26
                              END
     rest := CEIL (in_num / 26);
     IF  rest = 1
     THEN
          RETURN     return_txt;
     ELSE
          RETURN  to_abc (rest - 1) || return_txt;
     END IF;
END     to_abc;Test script (including your base26 function, for comparison):
COLUMN     base26          FORMAT     A10
COLUMN     right_txt     FORMAT     A10
COLUMN     to_abc          FORMAT     A10
SET     NULL     "[NULL]"
WITH test_nums     AS
     SELECT     0 AS n,     '-' AS right_txt     FROM dual     UNION ALL
     SELECT     1,        'A'               FROM dual     UNION ALL
     SELECT     10,        'J'               FROM dual     UNION ALL
     SELECT     26,        'Z'               FROM dual     UNION ALL
     SELECT     27,        'AA'               FROM dual     UNION ALL
     SELECT     28,        'AB'               FROM dual     UNION ALL
     SELECT     52,        'AZ'               FROM dual     UNION ALL
     SELECT     53,        'BA'               FROM dual     UNION ALL
     SELECT     78,        'BZ'               FROM dual     UNION ALL
     SELECT     79,        'CA'               FROM dual     UNION ALL
     SELECT     702,        'ZZ'               FROM dual     UNION ALL
     SELECT     703,        'AAA'               FROM dual     UNION ALL
     SELECT     1404,       'BAZ'               FROM dual     UNION ALL
     SELECT     1405,       'BBA'               FROM dual     UNION ALL
     SELECT     18278,     'ZZZ'               FROM dual     UNION ALL
     SELECT     18279,     'AAAA'               FROM dual     UNION ALL
     SELECT     18280,     'AAAB'               FROM dual     UNION ALL
     SELECT     NULL,     NULL               FROM dual
SELECT     n
,     to_abc (n)     AS to_abc
,     right_txt
,     CASE
          WHEN  NVL (to_abc (n), '??') =
                NVL (right_txt,  '??')
          THEN  ' '
          ELSE  '<== WRONG!'
     END             AS flag
,     base26 (n)     AS base26
FROM     test_nums
ORDER BY  n
;Results of test script:
.        N TO_ABC     RIGHT_TXT  FLAG       BASE26
         0 -          -                     [NULL]
         1 A          A                     a
        10 J          J                     j
        26 Z          Z                     aa
        27 AA         AA                    aa
        28 AB         AB                    ab
        52 AZ         AZ                    ba
        53 BA         BA                    ba
        78 BZ         BZ                    ca
        79 CA         CA                    ca
       702 ZZ         ZZ                    aaa
       703 AAA        AAA                   aaa
      1404 BAZ        BAZ                   bba
      1405 BBA        BBA                   bba
     18278 ZZZ        ZZZ                   aaaa
     18279 AAAA       AAAA                  aaaa
     18280 AAAB       AAAB                  aaab
[NULL]     [NULL]     [NULL]                [NULL]

Similar Messages

  • Letters instead of numbers in graph

    Hi OTN,
    In my ADF BC application I have a bar graph. The graph looks like this: http://img846.imageshack.us/img846/1812/graphn.png
    So, my question is: is there any possibility of replacing numbers on the top of bars with letters (1 is A, 2 is B and etc.)?
    Type of graph is dvt:barGraph, ADF BC, Jdeveloper 11.1.1.4

    Done in with custom converter.
    <dvt:markerText id="markerText1" rendered="true">
                    <dvt:y1Format autoPrecision="off">
                      <f:converter converterId="estimationFormatter"/>
                    </dvt:y1Format>
                </dvt:markerText>Even though JDeveloper marks it as error in page source, it works.

  • Keypad displays letters instead of numbers

    I'm trying to input my WPA key for wireless setup.  When I enter it, only letters show up and I'm unable to connect.

    Try holding down the Fn key and tap NumLock, see if this works ?
    If my reply was helpful please click the "Kudos" star.
    If your problem is solved please click the "Accept as Solution" button

  • Looping through letters instead of numbers

    I need to create an array of strings containing everything from A100 to X999.  I tried looping through letters but I don't think it can be done
    var arrayAct = new Array();
      for (i = "A"; i <= "X"; i++){
       for (i2 = 100; i2 <= 999; i2++){
        arrayAct.push(String(i+i2));

    excellent.  Final code is working:
    var arrayAct = new Array();
      for (i = "A".charCodeAt(0); i <= "X".charCodeAt(0); i++){
       for (i2 = 100; i2 <= 999; i2++){
        arrayAct.push(String.fromCharCode(i)+String(i2));

  • How to dial telephone numbers which have letters instead of digits?

    I'm new to Blackberry products & just bought a 8330 curve.  Unlike my other smartphones which had the option of a dial key pad, the Curve appears to have forgotten to include one.  When a telephone number is spelled out with letters instead of digits, how do I dial it?  For example: for my pharmacy refills I would dial 1-123-345-DRUG  or when calling a company after hours and reach its automated answer system which prompts you to key-in the party that you are looking for their last 4 letters of their name.  How do you do it.  Help.

    Hi and welcome to the forums!
    You can enter the alpha chacratars using the alt shift for nummerics.
    For example: 1-800-(alt-shift) -IFlYSWA
    The same applys when you are asked for alpha characters as in your example
    of search by person's name.
    Thanks,
    Please remember to resolve your thread. Put the check mark in the green box that contained your answer! Thanks
    Message Edited by Bifocals on 11-24-2008 06:45 PM
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

  • Midnight C.: two ways of launch, one - letters instead of lines. Why?

    I may launch Midnight Commander in a three ways. Two of them are OK. But the third will bring drawing borders with letters instead of lines.
    I'm using LXTerminal (I think it doesn't matter). Below there is screenshot with launch results.
    Launch commands:
    1) In terminal as a user :
    mc
    2) In terminal, becoming root at first:
    su -
    mc
    3) Launch button from a panel, launch as a user:
    lxterminal --command="sudo su -l root -c /usr/bin/mc"
    The first two ways are OK, third way will bring "broken" lines. Give me please an idea of what to search. Or how to fix broken lines?
    Last edited by Stack (2012-12-18 12:09:39)

    Thank you. 'sudo /usr/bin/mc' did the trick.
    In both cases lines are OK.
    2013-03-03
    It was locale setup issue for a user's session - no local proper set up was done. There was related issue. The bug was absence of locale environment setup for VNC sessions. I.e. a file to be launched along with VNC server's wake up staff must have proper "export" for LC_* and LANG variables. In my system the file is '~/.vnc/xstartup'. I'm shure there are other, may be more elegant, ways to set up system wide wanted locale settings, to be picked up automaticaly by a VNC server for every user. May be '~/.vnc/xstartup' code may be an implementation of another than mine approach.
    Last edited by Stack (2013-03-03 07:00:47)

  • When I try to share a Numbers spreadsheet with other Mac users, (via iMessages) it doesn't open on Numbers app but instead on Numbers for iCloud beta, on their browser.

    When I try to share a Numbers spreadsheet with other Mac users, (via iMessages) it doesn't open on Numbers app but instead on Numbers for iCloud beta, on their browser. and worse all the letters appear out of format and unreadable.
    Is there any option that i'm getting wrong
    How can we solve this.
    Usualy we use Google drive documents to share some spreadsheets, but we wanted to share the same document with numbers (that's much better) but it doesn't work as easily as in google drive and doesn't even remotely works how it was supposed.

    When I try to share a Numbers spreadsheet with other Mac users, (via iMessages) it doesn't open on Numbers app but instead on Numbers for iCloud beta, on their browser. and worse all the letters appear out of format and unreadable.
    Don't know why those letters wouldn't display properly; maybe something to do with their settings at Safari > Preferences > Advanced > Default Encoding or similar setting in whatever browser they are using. But it's really easy for them to download the document via the "wrench" in the Numbers for iCloud menu. Then they can open it in the Numbers app.
    For "real-time" collaboration, I think you all need to be accessing Numbers for iCloud via the browser.
    SG

  • How to create a counter (with fixed increment) in DME file

    Hi Experts,
    Is there a way to define a counter in one of the Segment/loop of DME (Such as number of invoices), where we have to increment the actual value of the counter reading by a fixed value, say 2. Example, if the counter can print the invoice numbers as 1,2,3, 4,5 etc. then it should rather print X+2 in each case, i.e. 3, 4, 5, 6, 7 and so on.
    Regards
    Harsh

    Hi Amitash,
    Thanks for the response. Sorry I couldn't articulate my question correctly. Let me try to rephrase.
    I have to print all the invoice details related to each payment document, in the DME output. One of the field in the invoice details is a simple counter, which prints a simple sequence number 1 to 5 (for 5 invoices). This counter can go upto any number depending on the number of invoices (1 to n). Now with the help of aggregation functions I am able to generate such a counter. But here is the twist now. Instead of printing 1 to 5, the counter should print 3 to 8. ( i.e. 1 to n, it should be printing 3 to n+2 ). Is that possible?
    Regards
    Harsh

  • How to change the color of letters instead of highlight the text when compare two documents

    Hello!!
    I have the Adobe Acrobat 9 Pro (Versión 9.0.0) and I need to compare two documents, but I want to show the diferences changing  the color of letters instead of highlight the text with any color. My boss tell me that other Acrobat version have this option, but I couldn't find it in this version.
    Could you help me on this topic??
    Thanks

    Hello!!
    I have the Adobe Acrobat 9 Pro (Versión 9.0.0) and I need to compare two documents, but I want to show the diferences changing  the color of letters instead of highlight the text with any color. My boss tell me that other Acrobat version have this option, but I couldn't find it in this version.
    Could you help me on this topic??
    Thanks

  • My numpad won't work. Instead of numbers, my cursor just moves slightly.

    my numpad won't work. there's a beep when i hit numlock and instead of numbers, my cursor just moves slightly. i figure it's something simple, but i'm not sure how to fix it.

    it's a mac mini with 10.5.6 on it. the keyboard is actually i think intended for a pc, but it worked fine for the mac. i also had a legit apple keyboard that worked fine as well. i think that i may have accidentally tweaked the preferences somehow, and it disabled my num lock.

  • Use of SUM and COUNT with GROUP BY

    All,
    I have a set like below:
    State DOB StartDt EndDt Desc Category MemberID SubID Code
    NC 2003-01-30 2014-01-01 2014-01-31 Child B 123456 2 38
    NC 2003-01-30 2014-01-01 2014-01-31 Child B 123456 2 39
    NC 2003-01-30 2014-02-01 2014-05-31 Child B 123456 2 38
    NC 2003-01-30 2014-02-01 2014-05-31 Child B 123456 2 39
    NC 2003-01-30 2014-06-01 2014-07-31 Child B 123456 2 38
    NC 2003-01-30 2014-06-01 2014-07-31 Child B 123456 2 39
    NC 2014-01-17 2014-01-01 2014-07-31 Infant S 456789 1 49
    NC 2014-02-04 2014-02-01 2014-07-31 Infant S 246376 3 49
    -- MemberID and SubID identify 1 member
    -- Member 123456 has 2 distinct "Code" i.e. 38,39 but each code has different "StartDt" and "EndDt"
    -- Expected Result
    State Desc Category CountOfDistinctCode TotalMonthsEnrolled
    NC Child B 2 (38 and 39 for same member) 7 months (1 + 4 + 2) (Difference between StartDt and EndDt:1 (1/31/2014 - 1/1/2014) + 4 (5/31/2014 - 2/1/2014).. )
    NC Infant S 2 (Same code 49 but different member) 13 months (7+6) (7/31/2014 - 1/1/2014 = 7 months + 7/31/2014 - 2/1/2014 = 6 months)
    I tried doing a count of distinct Code and the summing up the member months, grouped by State, Desc, Category, but I am not able to get 2 and 7 for child, it somehow calculates Months as 14 (7+7). Please let me know what you guys suggest.

    OK, so we need a different approach. We need a table of numbers, a concept that I discuss here:
    http://www.sommarskog.se/arrays-in-sql-2005.html#numbersasconcept
    (Only read down to the next header.)
    We join the numbers to temp table with BETWEEN over the numbers. Then we count the distinct combination of member ID and number.
    We also need to make an adjustment how to build the string for the DISTINCT. I initially assumed that your columns were integer, why I used str() which produces a right-adjusted fixed-length string of 10 characters. (The default, you can specify a different
    width as the second parameter.) But str() expects a float value as input, and will fail if for instance member id would be non-numeric. We cannot just concatenate the strings, since in that case (MemberID, SubID) = ('12345', '61') would be
    the same as ('123456', '1'). So we must convert to char to get fixed length. All that said, and some more test data added, here is a solution:
    CREATE TABLE #Test
    [State] CHAR(2),
    DOB DATE,
    StartDt DATE,
    EndDt DATE,
    [Desc] VARCHAR(8),
    Category CHAR(1),
    MemberID VARCHAR(10),
    SubID VARCHAR(2),
    Code VARCHAR(5)
    INSERT INTO #Test
    VALUES
    ('NC', '20130130', '20140101', '20140120', 'Child', 'B', '123456', '2', '38'),
    ('NC', '20130130', '20140121', '20140131', 'Child', 'B', '123456', '2', '39'),
    ('NC', '20130130', '20140201', '20140531', 'Child', 'B', '123456', '2', '38'),
    ('NC', '20130130', '20140401', '20140613', 'Child', 'B', '123456', '2', '39'),
    ('NC', '20130130', '20140601', '20140731', 'Child', 'B', '123456', '2', '38'),
    ('NC', '20130130', '20140614', '20140731', 'Child', 'B', '123456', '2', '39'),
    ('NC', '20130129', '20140601', '20140731', 'Child', 'B', '9123456', '1', '38'),
    ('NC', '20130129', '20140614', '20140831', 'Child', 'B', '9123456', '1', '39'),
    ('NC', '20140117', '20140101', '20140731', 'Infant', 'S', '456789', '1', '49'),
    ('NC', '20140204', '20140201', '20140731', 'Infant', 'S', '246376', '3', '49')
    SELECT * FROM #Test ORDER BY MemberID, StartDt, EndDt
    SELECT
    [State]
    , [Desc]
    , Category
    , COUNT(DISTINCT convert(char(10), MemberID) +
    convert(char(2), SubID) +
    convert(char(5), Code)) AS TotalCnt
    , COUNT(DISTINCT convert(char(10), MemberID) +
    convert(char(2), SubID) +
    str(N.Number)) AS CalMonths
    FROM #Test t
    JOIN Numbers N ON N.Number BETWEEN
    datediff(MONTH, '19000101', t.StartDt) AND
    datediff(MONTH, '19000101', t.EndDt)
    GROUP BY [State], [Desc], Category
    go
    DROP TABLE #Test
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Making a counter with enable and reset

    Hi.  
    First of all, I looked online for this solultion and no success.
    What I am trying to do is have a counter with enable and reset.  
    1.  Increment from 0 to 5 everytime true boolean is received.  Q, the output should then be 1
    2.  If boolean false is received, Q should be 0
    3.  Once the count reaches 5, reset the counter to 0 and repeat.
    4.  Step 1-3 only happens when enable is true.  Anytime enable is false, the process is stopped.
    Please help!
    Rose

    This is something called an Action Engine, closely related to "Functional Global Variables" (FGV) or "VI Globals" (VIG).  Basically, you have a While Loop with one or more Shift Registers acting as "memory" and an "Action" input (typically a Boolean or an Enum) that says what the Action should be.
    As you posed your problem, I'm unsure if you require one Boolean (Enable/Disable) or two (Enable/Disable and "Count").  This is a situation where having an Enum input and more "Actions" might be appropriate.  For example:
    Load      Save the Max Count (5 in your example) in a Shift Register
    Reset    Set the internal Count to 0
    Enable   Allow Count Action to proceed
    Disable  Don't allow Count Action to proceed
    Count    Increment counter if "enabled", and output current count
    Each time you call this VI (did I say that this should be written as a sub-VI, with inputs Action and Max Count, and output Current Count?), depending on the Action you wire in, you will either perform "setup" actions (Load, Reset, Enable, Disable) or "Counting" actions (Count).  Note that it is easy to modify it so that if the Counter is disabled (ooh, that's a good name for this sub-VI, "Counter", has a mnemonic ring to it), the output is, say, -1, "Not a Count", instead of (as I described it above) the last Count while Enabled.
    Action Engines (and similar constructs, where there's a While loop with "True" wired to the Stop terminal, useful as a "memory" unit) are pretty common in LabVIEW.  More accomplished LabVIEW users might also accomplish this with a Feedback loop, but I find that the "Do Once" loop shown above is easier for me to recognize and understand.
    Bob (hard to teach an old dog new tricks) Schor

  • Wired letters instead of hebrew

    We wrote a servlet that prints letters in different languages. In order to print the letters, we use:
    PrintWriter out = response.getWriter();
    out.println(letters);
    When we runs the servlet, the servlet prints wired letters instead of hebrew:
    for example:
    =?windows-1255?Q?=EE=...
    the problem is that we need to read the letters that was printed with other program. So, instead to read the hebrew letters, it read wired things.
    How do we make the servlet prints hebrew??
    (we using hebrew and english letters)
    please help us.
    thanks, Naor and Shay.

    It depends on the data and encoded data and the encoding used for output.
    In jsp, you can use <%@page %> to specify the charset (UTF-8) and then set the locale (Hebrew).
    Example jsp file:
    <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ page import="java.util.*"%>
    <%
    String hebrewString = ...... the hebrew string, eg: you get this from database, etc .... ;
    Locale locale = ..... Hebrew locale instance, check it at java.util.Locale javadoc ....;
    response.setLocale(locale);
    %>
    <HTML>
    <%=hebrewString%>
    </HTML>
    If this prints wrongly, then either you use wrong charset/encoding or the hebrew string is not constructed properly (eg: your database doesn't support UTF-8, so when you save the data previously, the string was actually corrupted, etc).
    If you can you write hebrew, you can make it straight like this:
    <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ page import="java.util.*"%>
    <%
    Locale locale = ..... Hebrew locale instance, check it at java.util.Locale javadoc ....;
    response.setLocale(locale);
    %>
    <HTML>
    .. Barukh Haba B'shem Adonai (in hebrew script) ..
    </HTML>
    You may use richedit or IDE which support UTF-8 ( not ANSI! ) to create the jsp file. ANSI editor which will corrupt the text you entered.
    In XP, the notepad for microsoft is able to save the text using UTF-8, this editor can be used safely.
    By default, IE have encoding for Hebrew, so it should show up correctly. If you're using linux/unix or different browser, perhaps you need to download the encoding first to be able to display correctly.
    If you don't know how to write hebrew, go to any hebrew website, copy some text and paste it in UTF-8 editor. If you see the word correctly pasted, then it supports UTF-8. Then, you can create the JSP file I mentioned above.
    rgds,
    Alex

  • How do I continue with running dates in numbers?

    How do I continue with running dates in numbers?  Using numbers with dates and need to have them autofill across instead of my typing them in manually.

    Hi jonles,
    Type a date then press enter. Click once on that cell and hover the cursor over the right hand side of the cell. This will show the Fill handle (yellow dot). Drag it to the right.
    That will fill by adding a day to each cell.
    To create a series, enter two dates (e.g. 1 Jan then 8 Jan). Select both and drag right to create a weekly series.
    Regards,
    Ian.

  • Unread VIP messages counter on iCloud shows wrong numbers

    Hi,
    I have VIP inboxes set up. They appear on my Mac, iPhone and iCloud.com. The unread VIP messages counter on my Mac and iPhone are showing the correct numbers of unread VIP messages. However, the counter on iCloud shows wrong numbers.
    Does anymore have the same experience?
    I deleted the VIP inbox on iCloud.com and re-created it. Then the issue was solved. Some days later, however, it started counting wrongly again.
    Example:
    Peter is a VIP for me.
    1. I receive 2 messages from Peter, so the unread VIP messages counter on my Mac, iPhone and iCloud.com raises to 2.
    2. I read both messages
    3. The unread VIP messages counter on my iPhone and Mac vanished, and so does the general unread mail counter.
    4. On iCloud.com, my general unread mail counter would also be 0 but the VIP unread mail counter would still be 2. The VIP inbox does not show any unread email, tough.
    Best regards,
    Marc

    I've reported this error twice via Apple's iCloud feedback page on the website - http://www.apple.com/feedback/icloud.html
    No solution as yet... but an earlier VIP bug (where, if the same contact sometimes sends as "@mac.com" and sometimes "@me.com", they had to have separate VIP mailboxes) was fixed. (At least, I think it was fixed: if you put all the relevant addresses against the same single contact in iCloud and delete any other instances of the contact with the same address, then iCloud creates one amalgamated VIP inbox for them. But I digress.)
    The mis-count bug has been around since the day VIP appeared - hopefully getting a bit embarrassing for someone on the iCloud team? Maybe someone at Apple reading this?

Maybe you are looking for

  • Recording MM03

    calling of  MM03 transaction From Report pgm giving the Material as I/P but while recording MM03 and and after executing the small icon(service for objects) that appear on the side of heading is not appearing .since that icon is needed for attachemen

  • NIO verses IO

    Hi All, I am using java NIO socketchannel and ByteBuffers for my client/Server communication. It is in blocking mode and single threaded. Problem Description: From the results it seems that my NIO program is taking more time than old java io. It look

  • Intel Mac Temperature Database Site

    Want to compare your MacBook's operating temperatures with other MacBook owners? Go here. "This site will help collect and show the temperatures of Apple Macintosh computers using the new processors by Intel. " http://www.intelmactemp.com/list -Bmer

  • Question--How to get streaming video?

    I have a MBP with 10.6.8., 1.66 intel, 4 GB/ 1067 Mhz DDR3 memory.  We have wireless and I have been informed that we don't use a fraction of our capacity. Nevertheless I dan't get streaming video. I get the audio and the video has to catch up.  I us

  • HT1766 icloud backup is gone

    i had a backup of 2,9 gb yesterday before i had reset my phone, now i wanna put it all back on my phone but it isn't there!! what can i do now? lol