473,671 Members | 2,484 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 5144
"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
11501
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
2123
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
3555
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
7688
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
2562
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
1843
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
2752
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
1843
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
8401
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
8824
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...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6236
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
5703
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
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.