473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Select with dummy rows when grouping?

If I select from a table and, for example, group by the month or day
to determine how much activity there is day to day or month to month,
it will only return months and days with a record and leave out any
month or day without any records making it apear at a glance that
every day or month has activity which forces me or whoever to have to
look at the date column and actively look for spots where a day or
more elapses without a single row in order to determine when nothing
has happened. Is there any select method for grouping on something
like a month and to have it output a dummy row for missing days or
months without having to write a program that makes an individual
select for each day?

Thanks!
Jul 19 '05 #1
2 5126
"JohnnyOnTheSpot" <an************@hotmail.com> wrote in message
news:e8**************************@posting.google.c om...
If I select from a table and, for example, group by the month or day
to determine how much activity there is day to day or month to month,
it will only return months and days with a record and leave out any
month or day without any records making it apear at a glance that
every day or month has activity which forces me or whoever to have to
look at the date column and actively look for spots where a day or
more elapses without a single row in order to determine when nothing
has happened. Is there any select method for grouping on something
like a month and to have it output a dummy row for missing days or
months without having to write a program that makes an individual
select for each day?

Thanks!


To my knowledge, MySQL cannot return records that don't exist, nor can it
predict sequences and generate output. (If I'm wrong, I'm sure someone here
will quickly correct me, wouldn't be the first time :-) Can you enter a
dummy record into the table for days with no activity? That is the only way
I can think of to do what you want. If you were to start each day by
entering an empty record for that day, then you would get at least one hit
for each day in a weekly or monthly query, thus solving your problem.

JM
Jul 19 '05 #2
"JohnnyOnTheSpot" <an************@hotmail.com> wrote in message
news:e8**************************@posting.google.c om...
If I select from a table and, for example, group by the month or day
to determine how much activity there is day to day or month to month,
it will only return months and days with a record and leave out any
month or day without any records making it apear at a glance that
every day or month has activity which forces me or whoever to have to
look at the date column and actively look for spots where a day or
more elapses without a single row in order to determine when nothing
has happened. Is there any select method for grouping on something
like a month and to have it output a dummy row for missing days or
months without having to write a program that makes an individual
select for each day?

Thanks!


To my knowledge, MySQL cannot return records that don't exist, nor can it
predict sequences and generate output. (If I'm wrong, I'm sure someone here
will quickly correct me, wouldn't be the first time :-) Can you enter a
dummy record into the table for days with no activity? That is the only way
I can think of to do what you want. If you were to start each day by
entering an empty record for that day, then you would get at least one hit
for each day in a weekly or monthly query, thus solving your problem.

JM
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JohnnyOnTheSpot | last post by:
If I select from a table and, for example, group by the month or day to determine how much activity there is day to day or month to month, it will only return months and days with a record and...
5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
4
by: Mick White | last post by:
mysql> select * from guestbook; +----+--------+---------+-----------------+----------------+ | id | fname | lname | comments | time_in |...
1
by: Volt | last post by:
is there any way to select and mark part of text in textarea by regular expression? i need to select the first string in textarea whitch is like xxxxx,xxx where x is any character
12
by: TP | last post by:
Here is my problem. I need to display a table about which I have no information except the table name. Using metadata I can somehow show the column names and record values. But my table has 1...
4
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
3
by: Tim Smith | last post by:
I've been benchmarking some very simple databases. By simple, I mean a table like this: CREATE TABLE bench ( id SERIAL, data TEXT ) CREATE INDEX bench_data_index ON bench (data) which is...
2
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but...
4
by: scalda34 | last post by:
This in Access 2003. Pardon me if this is in the wrong spot, but I hoped someone could help. I have a table with multiple records that have a text represented date field. The date is in a format...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.