SQL - Zahlenfolge erzeugen

How to generate a sequence of numbers in SQL

Generating a number sequence

There's some use for a number sequence. For example a recordset with an index. If for a specific indes there's no entry, the index is not contained in the set. By joining the set to the full sequence of indices, absent entries show up as empty rows.

No loops

Loops of single statements are possible in SQL but expensive

Cartesian product

Das Cartesian product of two sets is the set of all pairs that can be arranged from one element of either set. Thus, the numbers 0 bis 99 are the Cartesian produkt of the sets (0...9) and (0, 10,...,90). The vector of the tens is the vector of ones, multiplied by 10.

Sample Code

 

 

ERROR: Content Element with uid "287" and type "dce_codesnippet" has no rendering definition!

Comments and Responses

×

Name is required!

Enter valid name

Valid email is required!

Enter valid email address

Comment is required!

Be the First to Comment
Top