473,397 Members | 2,116 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,397 software developers and data experts.

HELP -- Not a true xtab, but similar, on 2 columns/fields

Environment is MySQL 3.23.33, PHP Version 4.3.2.

Have included a couple of extra columns here in an attempt to clarify what
I am trying to do. In the table rid is a unique, auto-increment. The fields
date_created and date_updated are datetime format yyyymmdd hh:mm:ss.
Passing a begining and ending date format of mm-yyyy as begdate 06-2003
and endate 11-2003 into a single table query like ;

*Code:*

SELECT (date_format(date_created,'%m - %Y')) as RptMonth
, SUM(IF(date_created != \"0000-00-00\", 1,0)) AS NEW
, date_format(date_created,'%m - %Y')) as Created
, SUM(IF(date_updated != \"0000-00-00\", 1,0)) AS Upd
, date_format(date_updated,'%m - %Y')) as Updated
from activity_table
where (
(date_format(date_created,'$daform') between \"$begdate\" and
\"$enddate\") or
(date_format(date_updated,'$daform') between \"$begdate\" and
\"$enddate\")
)
group by rid

Grouping by rid just to ensure that all rows are returned and to use the
SUM functioan. Injected > and >> manually in the following table to
highlight
what I will be trying to explain in a minute. Results is a series of rows
(small representative set is shown here).

*Code:*

Activity For period of Jun/2003 to Nov/2003
RptMonth New Created Upd Updated Total
07 - 2003 1 07 - 2003 0 00 - 0000 1
07 - 2003 1 07 - 2003 0 00 - 0000 2
07 - 2003 1 07 - 2003 0 00 - 0000 3
07 - 2003 1 07 - 2003 0 00 - 0000 4
07 - 2003 1 07 - 2003 0 00 - 0000 5
07 - 2003 1 > 07 - 2003 1 >> 09 - 2003 6
08 - 2003 1 08 - 2003 0 00 - 0000 7
08 - 2003 1 08 - 2003 0 00 - 0000 8
08 - 2003 1 08 - 2003 0 00 - 0000 9
09 - 2003 1 09 - 2003 0 00 - 0000 10
10 - 2003 1 10 - 2003 0 00 - 0000 11
10 - 2003 1 10 - 2003 0 00 - 0000 12
10 - 2003 1 10 - 2003 0 00 - 0000 13
10 - 2003 1 10 - 2003 0 00 - 0000 14
10 - 2003 1 10 - 2003 0 00 - 0000 15
11 - 2003 1 11 - 2003 0 00 - 0000 16

I am certain that a query can return a table that is like my desired
output, but I am absolutely stuck on geting the results set. Desired
output would be a table that looks like the following, note that the >>
wouldn't actually be displayed it is added here, just to show where that
row highlighted above would get counted. Also the Total is decremented
by that 1. In the actual output I wouldn't even display the Created or
Updated date.

*Code:*

Activity For period of Jun/2003 to Nov/2003
RptMonth New Created Upd Updated Total
07 - 2003 6 > 07 - 2003 0 00 - 0000 6
08 - 2003 3 08 - 2003 0 00 - 0000 9
09 - 2003 1 09 - 2003 1 >> 09 - 2003 10
10 - 2003 5 10 - 2003 0 00 - 0000 15
11 - 2003 1 11 - 2003 0 00 - 0000 16

I have tripped and ripped and fallen all over myself on this, and think
that it is something like - maybe i have to pass an array, concat and
sum by date_xxx and beg-enddate (gasp) or something that is mysteriously
related to the phase of the moon, I just can't seem to get it:

*Code:*

SELECT (date_format(date_created,'%m - %Y')) as RptMonth
, SUM(IF(date_created != \"0000-00-00\", 1,0)) AS NEW
, date_format(date_created,'%m - %Y')) as Created
, SUM(IF(date_updated != \"0000-00-00\", 1,0)) AS Upd
, date_format(date_updated,'%m - %Y')) as Updated
from activity_table
where (
(date_format(date_created,'%Y%m') between \"$begdate\" and
\"$enddate\") or
(date_format(date_updated,'%Y%m') between \"$begdate\" and \"$enddate\")
)
group by RptMonth


Anybody offer any thoughts or wisdom on this? Welcome all of them, as
your idea might just kick my brains cells in another direction.

TIA

Jul 19 '05 #1
0 1180

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

Similar topics

0
by: nospam1001 | last post by:
Environment is MySQL 3.23.33, PHP Version 4.3.2. Have included a couple of extra columns here in an attempt to clarify what I am trying to do. In the table rid is a unique, auto-increment. The...
0
by: user | last post by:
Environment is MySQL 3.23.33, PHP Version 4.3.2. Have included a couple of extra columns here in an attempt to clarify what I am trying to do. In the table rid is a unique, auto-increment. The...
2
by: Proteus | last post by:
I'm running Access 97 on Windows 98. I need to make large tables and queries with approaching but not exceeding 225 fields (columns). Access is giving me a "too many fields" message when I try to...
4
by: Proteus | last post by:
I'm running Access 97 on Windows 98. I need to make large tables and queries with approaching but not exceeding 225 fields (columns). Access is giving me a "too many fields" message when I try to...
10
by: mscurto | last post by:
What is the syntax for an sql command to get the following. I want to pull in a handful of fields from a table but one of the fields needs to be unique. For example, if I have a customer table...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
1
by: ReubenPatterson | last post by:
Very newbie question...I have an xTab query that sums records by a simple: TRANSFORM Count(TBLMaster.FldChannelNumb) AS CountOfFldChannelName SELECT TBLMaster.FldChannelNumb,...
2
by: yeshello54 | last post by:
so here is my problem...in a contact manager i am trying to complete i have ran into an error..we have lots of code because we have some from class which we can use...anyways i keep getting an error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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...
0
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...

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.