Friday, March 9, 2012

Query to create a countable list using a single value from table

Hi,
from a single numeric value, say 'n', in a field in a table, i'd like to create a SELECT query that produces a list from 1 to n, e.g
if the value was 6, I would like selected back:
1
2
3
4
5
6
Any pointers?
GregWhy?|||I'm developing a system using an Enterprise product, Metastorm e-work, that sits above SQL server. Given a Quantity value, I want to make a drop down list of the values from 1 to Quantity using the form designer that comes with the product, to allow a user to change this value.

I'd like to do something more sophisticated than my posted request, but if there is SQL code available to do this, it will get me on the way.

g.|||CREATE a numbers TABLE...

SELECT Col1 from myTable99
WHERE Col1 <= @.value

You'll use it for more than just this...|||Cheers.|||Originally posted by Brett Kaiser
You'll use it for more than just this...

so true

similar example: generating sequential dates
see The integers table (http://searchdatabase.techtarget.com/ateQuestionNResponse/0,289625,sid13_cid569539_tax285649,00.html)
(site registration may be required, but it's free)

No comments:

Post a Comment