473,789 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5158
"JohnnyOnTheSpo t" <an************ @hotmail.com> wrote in message
news:e8******** *************** ***@posting.goo gle.com...
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
"JohnnyOnTheSpo t" <an************ @hotmail.com> wrote in message
news:e8******** *************** ***@posting.goo gle.com...
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
619
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 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...
5
11509
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 { CarsSoldID int (primary key) MonthID int DealershipID int NumberCarsSold int
4
2129
by: Mick White | last post by:
mysql> select * from guestbook; +----+--------+---------+-----------------+----------------+ | id | fname | lname | comments | time_in | +----+--------+---------+-----------------+----------------+ | 1 | Mick | White | Test 123 | 20050303191815 | | 2 | Ann | White | Hello World | 20050303191931 | | 3 | Ann | White | It's a nice day | 20050303191959 | | 4 | Seamus | White | The cat |...
1
3576
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
7702
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 million rows and if I do a select * then I do get 1 million rows. I want to be able to provide page navigation as google does, page
4
2575
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 contents on certain fields. The grouping/filtering is "remembered" for each user via a cookie. The problem is works like this: User A applies a filter on Project Manager. User B filters by Department. User B groups by Project Manager (NOTE -...
3
1848
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 filled with 100k records, where the data values for each record are distinct (the data for record N is "text_item_N").
2
2762
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 then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
4
1846
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 like: "06/01/2009" I need to select all the fields from the table but only the 6 oldest rows that fall in a range for each group of "DocType, PayTo, ContactName, ContactNumber, DocFooter, PQBName, LetterDate, RetireeFirstName, RetireeLastName,...
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.