Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3596538
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:00:03+00:00 2026-05-18T20:00:03+00:00

I need to write a SQL query to print the following aphanumberic sequence in

  • 0

I need to write a SQL query to print the following aphanumberic sequence in SQL

0001,
0002,
… ,
0009,
000A,
… ,
000Z,
… ,
0010,
0011,
… ,
001A,
… and so on till… ,
ZZZZ

please note: all characters are UPPERCASE.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:00:04+00:00Added an answer on May 18, 2026 at 8:00 pm

    You could create a function like this:

    create function to_base_36 (n integer) return varchar2
    is
      q integer;
      r varchar2(100);
    begin
      q := n;
      while q >= 36 loop
         r := chr(mod(q,36)+case when mod(q,36) < 10 then 48 else 55 end) || r;
         q := floor(q/36);
      end loop;
      r := chr(mod(q,36)+case when mod(q,36) < 10 then 48 else 55 end) || r;
      return lpad(r,4,'0');
    end;
    

    and then use it like this:

    select rownum, to_base_36(rownum)
    from dual
    connect by level < 36*36*36*36;
    

    Or, without creating a function:

    with digits as
    ( select n, chr(mod(n,36)+case when mod(n,36) < 10 then 48 else 55 end) d
      from (Select rownum-1 as n from dual connect by level < 37)
    )
    select d1.n*36*36*36 + d2.n*36*36 + d3.n*36 + d4.n, d1.d||d2.d||d3.d||d4.d
    from digits d1, digits d2, digits d3, digits d4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a SQL query to print the following aphanumberic sequence in
I need to write SQL Query to Retrive the Following Settings of SQL Logins
I need to write a SQL query which will get me those rows from
Since i'm a poor sql developer, i need support to write a sql query
I need to write some sql that will allow me to query all objects
I need to write a query on SQL server to get the list of
Im very new to SQL but need to write a query to do the
Ok this is driving me nuts, I need to write an SQL query that
I need to write a SQL-Server query but I don't know how to solve.
I need to write a SQL Query for Advance search form shown as Image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.