![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table that I am pulling results from, but there are missing days. i.e. Select id, date, count from table: id * * date * * * * count 1 * * 2/1/2010 * * 10 2 * * 2/3/2010 * * *5 3 * * 2/4/2010 * * *4 4 * * 2/5/2010 * * *2 As you can see in my simplified example I do not have any data for 2/2/2010 What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. I'd like my data set to look like this: id * * date * * * * count 1 * * 2/1/2010 * * 10 * * * *2/2/2010 * * *0 2 * * 2/3/2010 * * *5 3 * * 2/4/2010 * * *4 4 * * 2/5/2010 * * *2 I know how to pull all dates in a month or date range within oracle, but cannot figure out a way with mysql.. any ideas? |
#3
| |||
| |||
|
|
I have a table that I am pulling results from, but there are missing days. i.e. Select id, date, count from table: id * * date * * * * count 1 * * 2/1/2010 * * 10 2 * * 2/3/2010 * * *5 3 * * 2/4/2010 * * *4 4 * * 2/5/2010 * * *2 As you can see in my simplified example I do not have any data for 2/2/2010 What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. I'd like my data set to look like this: id * * date * * * * count 1 * * 2/1/2010 * * 10 * * * *2/2/2010 * * *0 2 * * 2/3/2010 * * *5 3 * * 2/4/2010 * * *4 4 * * 2/5/2010 * * *2 I know how to pull all dates in a month or date range within oracle, but cannot figure out a way with mysql.. any ideas? |
#4
| |||
| |||
|
|
On 5 Feb, 19:00, master44 <trp... (AT) gmail (DOT) com> wrote: What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. One common way is to generate a calendar table and ... |
#5
| |||
| |||
|
|
Lennart: On 5 Feb, 19:00, master44 <trp... (AT) gmail (DOT) com> wrote: What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. One common way is to generate a calendar table and ... This is such a common situation (a true FAQ), that I would expect a database management system to have such table 'on board'. Isn't it amazing, that merely every application in this World (using MySQL) has to generate its own calendar table? Am I the only one who thinks this is a shortcoming of MySQL (if such table is indeed not built-in)? |
#6
| |||
| |||
|
|
Lennart: On 5 Feb, 19:00, master44 <trp... (AT) gmail (DOT) com> wrote: What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. One common way is to generate a calendar table and ... This is such a common situation (a true FAQ), that I would expect a database management system to have such table 'on board'. Isn't it amazing, that merely every application in this World (using MySQL) has to generate its own calendar table? Am I the only one who thinks this is a shortcoming of MySQL (if such table is indeed not built-in)? I've got about 50 tables and I've never needed that one. |
#7
| |||
| |||
|
|
Erick T. Barkhuis wrote: Lennart: On 5 Feb, 19:00, master44 <trp... (AT) gmail (DOT) com> wrote: What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. One common way is to generate a calendar table and ... This is such a common situation (a true FAQ), that I would expect a database management system to have such table 'on board'. Isn't it amazing, that merely every application in this World (using MySQL) has to generate its own calendar table? Am I the only one who thinks this is a shortcoming of MySQL (if such table is indeed not built-in)? I've got about 50 tables and I've never needed that one. |
|
I'd far rather see a much more common situation addressed: namely many to one correspondences implicitly connecting table fields and records. |
|
So that when e.g. I find the same customer on the database in four separate instances, I could easily combine them and all his orders would magically now attach to the same person. |
#8
| |||
| |||
|
|
The Natural Philosopher: Erick T. Barkhuis wrote: Lennart: On 5 Feb, 19:00, master44 <trp... (AT) gmail (DOT) com> wrote: What I'd like to do is join this query to something that selects all the days for a date range so that I can make sure I account for every day in a given month. One common way is to generate a calendar table and ... This is such a common situation (a true FAQ), that I would expect a database management system to have such table 'on board'. Isn't it amazing, that merely every application in this World (using MySQL) has to generate its own calendar table? Am I the only one who thinks this is a shortcoming of MySQL (if such table is indeed not built-in)? I've got about 50 tables and I've never needed that one. So, how do you show the number of orders for each calender day in the system described below? I'd far rather see a much more common situation addressed: namely many to one correspondences implicitly connecting table fields and records. You mean: foreign keys? Doesn't InnoDB address this? So that when e.g. I find the same customer on the database in four separate instances, I could easily combine them and all his orders would magically now attach to the same person. I'm totally lost...how do you recognize "the same customer in four instances" when not by unique ID? And if that's how you recognize them, how can there be more than one of the same customer in the customer table at all? Sounds like you simply haven't normalized your database, or you allow entry of "the same customer" multiple times in your application (which would automatically mean, that two same curstomers are in fact separate customers in that system). |
#9
| |||
| |||
|
|
Op 6-2-2010 14:20, Erick T. Barkhuis schreef: Sounds like you simply haven't normalized your database, or you allow entry of "the same customer" multiple times in your application (which would automatically mean, that two same curstomers are in fact separate customers in that system). but customers can merge into one new customer speyker + saab ==> speyker there where 2, now there's only 1.... |
#10
| |||
| |||
|
|
but customers can merge into one new customer speyker + saab ==> speyker there where 2, now there's only 1.... |
![]() |
| Thread Tools | |
| Display Modes | |
| |