PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Can you select future dates that do not yet exist in table?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Can you select future dates that do not yet exist in table?

Réponse
 
LinkBack Outils de la discussion
Vieux 17/10/2007, 00h57   #1
sparky
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Can you select future dates that do not yet exist in table?

I have a program I'm working on that does has a graph to show what is
the future estimate of production of eggs from a bunch of different
farmers.

The table I have is this:
CREATE TABLE `henbatch` (
`henBatch_ID` int(11) NOT NULL auto_increment,
`Barn_ID` int(11) NOT NULL,
`Quantity` int(11) NOT NULL,
`StartDate` date default NULL,
`SlaughteredDate` date default NULL,
`StartDateSet` tinyint(1) default NULL,
`Received` tinyint(1) NOT NULL,
PRIMARY KEY (`henBatch_ID`)
)

StartdateSet is there because of something that I was thinking should
work, but don't know anymore if it will.

What I need to do is to select from this table for future entries that
might not yet have been entered. I need to group weekly or maybe
monthly the estimated sum of hens that are still in production. In
another table the barn has the lifetime for the batch of hens. Can
someone give me a suggestion on how to do this? Can this be done just
with a select statement from this table? Any questions, please ask.
- It's hard to explain.

Thanks

  Réponse avec citation
Vieux 17/10/2007, 03h17   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can you select future dates that do not yet exist in table?

sparky wrote:
> I have a program I'm working on that does has a graph to show what is
> the future estimate of production of eggs from a bunch of different
> farmers.
>
> The table I have is this:
> CREATE TABLE `henbatch` (
> `henBatch_ID` int(11) NOT NULL auto_increment,
> `Barn_ID` int(11) NOT NULL,
> `Quantity` int(11) NOT NULL,
> `StartDate` date default NULL,
> `SlaughteredDate` date default NULL,
> `StartDateSet` tinyint(1) default NULL,
> `Received` tinyint(1) NOT NULL,
> PRIMARY KEY (`henBatch_ID`)
> )
>
> StartdateSet is there because of something that I was thinking should
> work, but don't know anymore if it will.
>
> What I need to do is to select from this table for future entries that
> might not yet have been entered. I need to group weekly or maybe
> monthly the estimated sum of hens that are still in production. In
> another table the barn has the lifetime for the batch of hens. Can
> someone give me a suggestion on how to do this? Can this be done just
> with a select statement from this table? Any questions, please ask.
> - It's hard to explain.
>
> Thanks
>
>


If they haven't been entered, how can you select them? SELECT only
returns what's in the database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 17/10/2007, 05h18   #3
ZeldorBlat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can you select future dates that do not yet exist in table?

On Oct 16, 9:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> sparky wrote:
> > I have a program I'm working on that does has a graph to show what is
> > the future estimate of production of eggs from a bunch of different
> > farmers.

>
> > The table I have is this:
> > CREATE TABLE `henbatch` (
> > `henBatch_ID` int(11) NOT NULL auto_increment,
> > `Barn_ID` int(11) NOT NULL,
> > `Quantity` int(11) NOT NULL,
> > `StartDate` date default NULL,
> > `SlaughteredDate` date default NULL,
> > `StartDateSet` tinyint(1) default NULL,
> > `Received` tinyint(1) NOT NULL,
> > PRIMARY KEY (`henBatch_ID`)
> > )

>
> > StartdateSet is there because of something that I was thinking should
> > work, but don't know anymore if it will.

>
> > What I need to do is to select from this table for future entries that
> > might not yet have been entered. I need to group weekly or maybe
> > monthly the estimated sum of hens that are still in production. In
> > another table the barn has the lifetime for the batch of hens. Can
> > someone give me a suggestion on how to do this? Can this be done just
> > with a select statement from this table? Any questions, please ask.
> > - It's hard to explain.

>
> > Thanks

>
> If they haven't been entered, how can you select them? SELECT only
> returns what's in the database.
>
> --


Right -- don't underestimate the usefulness of a "calendar" table.
Just create a table that has every date in it for a reasonable range.
You can then start with this table, outer join your other tables, and
get a row for every date -- even if there's nothing in your "henbatch"
table.

You may find it to be useful for other things, too -- in our
application we use it to keep track of business days and holidays so
we know when to skip processing for a day.

  Réponse avec citation
Vieux 17/10/2007, 09h00   #4
strawberry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can you select future dates that do not yet exist in table?

On 17 Oct, 04:18, ZeldorBlat <zeldorb...@gmail.com> wrote:
> On Oct 16, 9:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
>
> > sparky wrote:
> > > I have a program I'm working on that does has a graph to show what is
> > > the future estimate of production of eggs from a bunch of different
> > > farmers.

>
> > > The table I have is this:
> > > CREATE TABLE `henbatch` (
> > > `henBatch_ID` int(11) NOT NULL auto_increment,
> > > `Barn_ID` int(11) NOT NULL,
> > > `Quantity` int(11) NOT NULL,
> > > `StartDate` date default NULL,
> > > `SlaughteredDate` date default NULL,
> > > `StartDateSet` tinyint(1) default NULL,
> > > `Received` tinyint(1) NOT NULL,
> > > PRIMARY KEY (`henBatch_ID`)
> > > )

>
> > > StartdateSet is there because of something that I was thinking should
> > > work, but don't know anymore if it will.

>
> > > What I need to do is to select from this table for future entries that
> > > might not yet have been entered. I need to group weekly or maybe
> > > monthly the estimated sum of hens that are still in production. In
> > > another table the barn has the lifetime for the batch of hens. Can
> > > someone give me a suggestion on how to do this? Can this be done just
> > > with a select statement from this table? Any questions, please ask.
> > > - It's hard to explain.

>
> > > Thanks

>
> > If they haven't been entered, how can you select them? SELECT only
> > returns what's in the database.

>
> > --

>
> Right -- don't underestimate the usefulness of a "calendar" table.
> Just create a table that has every date in it for a reasonable range.
> You can then start with this table, outer join your other tables, and
> get a row for every date -- even if there's nothing in your "henbatch"
> table.
>
> You may find it to be useful for other things, too -- in our
> application we use it to keep track of business days and holidays so
> we know when to skip processing for a day.


Just add each date one at a time for the next millenia.... or follow
this thread... http://datacharmer.blogspot.com/2006_06_01_archive.html

  Réponse avec citation
Vieux 17/10/2007, 19h59   #5
sparky
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can you select future dates that do not yet exist in table?

On Oct 17, 1:00 am, strawberry <zac.ca...@gmail.com> wrote:
> On 17 Oct, 04:18, ZeldorBlat <zeldorb...@gmail.com> wrote:
>
>
>
> > On Oct 16, 9:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:

>
> > > sparky wrote:
> > > > I have a program I'm working on that does has a graph to show what is
> > > > the future estimate of production of eggs from a bunch of different
> > > > farmers.

>
> > > > The table I have is this:
> > > > CREATE TABLE `henbatch` (
> > > > `henBatch_ID` int(11) NOT NULL auto_increment,
> > > > `Barn_ID` int(11) NOT NULL,
> > > > `Quantity` int(11) NOT NULL,
> > > > `StartDate` date default NULL,
> > > > `SlaughteredDate` date default NULL,
> > > > `StartDateSet` tinyint(1) default NULL,
> > > > `Received` tinyint(1) NOT NULL,
> > > > PRIMARY KEY (`henBatch_ID`)
> > > > )

>
> > > > StartdateSet is there because of something that I was thinking should
> > > > work, but don't know anymore if it will.

>
> > > > What I need to do is to select from this table for future entries that
> > > > might not yet have been entered. I need to group weekly or maybe
> > > > monthly the estimated sum of hens that are still in production. In
> > > > another table the barn has the lifetime for the batch of hens. Can
> > > > someone give me a suggestion on how to do this? Can this be done just
> > > > with a select statement from this table? Any questions, please ask.
> > > > - It's hard to explain.

>
> > > > Thanks

>
> > > If they haven't been entered, how can you select them? SELECT only
> > > returns what's in the database.

>
> > > --

>
> > Right -- don't underestimate the usefulness of a "calendar" table.
> > Just create a table that has every date in it for a reasonable range.
> > You can then start with this table, outer join your other tables, and
> > get a row for every date -- even if there's nothing in your "henbatch"
> > table.

>
> > You may find it to be useful for other things, too -- in our
> > application we use it to keep track of business days and holidays so
> > we know when to skip processing for a day.

>
> Just add each date one at a time for the next millenia.... or follow
> this thread...http://datacharmer.blogspot.com/2006_06_01_archive.html


Thank you strawberry and ZeldorBlat. I realized last night I would
probably have to create the dates table. I now have that table, but
I'm not quite sure yet how to query these tables with a group by so
that it will give me the proper result.

Say I have daily entries in the dates table, and I want to get a
forcast for the next 2 years, grouped by month, how do I prevent one
hen batch from summing up multiple times per month? Or should I add
another column to the dates table to specify that these are weekly,
daily and monthly dates?

Thanks


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18645 seconds with 13 queries