|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|