Create List/sequence from nothing e.g. 1,2,3,4,5,.....,99,100

How can i create a sequence of numbers or dates from nothing! i.e. i want a list of numbers 1 to 100 without referencing a table.

leathamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

m1tk4Commented:
If you just need them to be a part of WHERE clause (because that's the only case where I see NOT wanting a table to make sense) you can do

select * from mytable where myfield in (1,2,3,4,5,6,7,8,9,10 ..and so on... 99,100);
0
leathamAuthor Commented:
I have some very heafty queries that i need to run based on a list of dates. at the moment i use a table that has a list of dates and i simply join the dates table to a subquery of the main query to limit the amount of data that is being retrieved.

The problem is that anyone running this query is limited to the dates in the table. I want one user to be able to run the query based on a different set of dates from the an other user at the same time.

If i can know how to run a series of numbers then i can generate the dates. what is the 'in' part of your query do?

Thanks
0
m1tk4Commented:
(myfield in (1,2,3)) will return a boolean true if myfield=2 and boolean false if myfield=4. You can do the same with dates instead of integers.

Now, your list of dates - what is it really, list of working days, all tuesdays, something else? Maybe you can work out a common rule to describe the dates you are interested in instead of using a "table function".
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

leathamAuthor Commented:
I simply need a list if consecutive dates. I know how to filter a list, i was just wondering if this was possible without referencing a table.
0
m1tk4Commented:
if they are consecutive, why can't you use

(d between startDate and endDate)

?
0
earth man2Commented:
select generate_series(1,20,2), to_date('29-JAN-2002','DD-MON-YYYY') + generate_series(1,147,7);
0
earth man2Commented:
select generate_series(1,100);
0
earth man2Commented:
I need to read the docs before I give you bad information...

select * from generate_series(1,100);

select current_date + s.a as dates from generate_series(0,14,7) as s(a);

http://www.postgresql.org/docs/8.1/static/functions-srf.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.