Re: Query Question: How to select all days within a period
On May 5, 3:00*pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
> On May 5, 8:37 am, supagroova <supagro...@gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I have what I think is a rather a curly question:
>
> > Is there a way to select all days in a month (or week, year, any
> > period) without having matching rows in a table?
>
> > So in essence, can I create a query that returns all the days in a
> > period without looking up a table?
>
> > To give some background, I am trying to output records for a graphing/
> > reporting tool and I only have non-zero records in my table.
>
> > Any insights, suggestions are warmly welcomed!
>
> > Thanks.
>
> Not that I know of other than creating a temporary table then filling
> it with values. *It isn't uncommon to have a "calendar" table that
> just includes every date within some reasonable range. *You'd be
> surprised at how much easier that makes some things -- then it's just
> an outer join from that table and you have all your zeros.
I absolutely agree with Zaldor. I usually have a `sequence` table
running from 1..366 for all days in a year. Very helpful indeed
|