Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

max, avg problem

Status
Not open for further replies.

rock786143

Programmer
Aug 12, 2009
20
0
0
IN
Hi,

I have a stored procedure which gives the data as following every day:

+--------------+---------------------+-------+
IPAddress AcctTime count

+--------------+---------------------+-------+
10.10.10.2 2009-03-21 00:00:00 9
10.10.10..2 2009-03-21 00:01:00 4

....................................................................|
10.10.10.4|2009-03-21 23:59:00|10
+--------------+---------------------+-------+

I trying to get the following data from the table
table report for day:
Columns: Max Count/min, Avg count/min, Max Count/hour, Max Hour, Avg Count/hour
Rows: All , Row per IPAddress

How do i get this in a single report?
I can create group on ip and i can get Max Count/min, Avg count/min but how to get next fields.

Please suggest a method. Thanks in advance.
 
You've not said what you are doing already. If you are getting your answer by grouping by minutes, then have a higher-level grouping using hours.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
show your sql formula for the stored procedure

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Here is my procedure:

CREATE DEFINER=`root`@`localhost` PROCEDURE `tablereport`(in ReportStarttime datetime)
BEGIN
DECLARE V1 DATETIME;
DECLARE V2 DATETIME;
DECLARE V3 DATETIME;
DECLARE constimeinterval varchar(15);
DECLARE NASIPMIN VARCHAR(15);
DECLARE NASIPMAX VARCHAR(15);
DECLARE NASIPCUR VARCHAR(15);
DECLARE count INT;
set constimeinterval='0:01:0';

set V1=ReportStarttime;
set V3=ADDTIME(V1,'1 0:0:0.000000');
select min(nasipaddress) into nasipmin from radiusacct where AcctStopTime>=ReportStarttime and AcctStopTime<=V3;
select max(nasipaddress) into nasipmax from radiusacct where AcctStopTime>=ReportStarttime and AcctStopTime<=V3;
set nasipcur=nasipmin;

incrementip: LOOP


set V1=ReportStarttime;
set V3=ADDTIME(V1,'1 0:0:0.000000');

incrementstartdate: LOOP
set V2=ADDTIME(V1,constimeinterval);

IF v2 > V3 THEN
LEAVE incrementstartdate;
END IF;

select count(acctsessionid) into count from radiusacct where AcctStopTime >= V1 and AcctStopTime <V2 and nasipaddress=nasipcur;
insert into tablerpt (AcctStopTime,nasipaddress,count) values(V1,nasipcur,count);
set V1=V2;
set V2= ADDTIME(V1,constimeinterval);

END LOOP incrementstartdate;

IF nasipcur >= nasipmax THEN
LEAVE incrementip;
END IF;
select min(nasipaddress) into nasipcur from radiusacct where nasipaddress> nasipmin and AcctStopTime>=ReportStarttime and AcctStopTime<V3;
set nasipmin=nasipcur;
END LOOP incrementip;
END

table structure:
mysql> desc tablerpt;
+--------------+-------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------------------+-------+
| NASIPAddress | varchar(15) | NO | | | |
| AcctStopTime | datetime | NO | | 0000-00-00 00:00:00 | |
| count | bigint(20) | YES | | NULL | |
+--------------+-------------+------+-----+---------------------+-------+
3 rows in set (0.00 sec)

I'm trying get a report in tabular format:
Columns: Max Count/min, Avg count/min, Max Count/hour, Max Hour, Avg Count/hour
Rows: All , Row per IPAddress

Please help me.
 
You're doing work in the SQL procedure that is better done in Crystal.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
>>You're doing work in the SQL procedure that is better done in Crystal.

Please suggest me how to do this in Crystal. Any sample formula would be appreciated.
 
Cystal does most of the work for you, once you get used to its ways. I suggest you take a few hours to do a few test reports and learn how it works. It will save time in the long run.

The use of Crystal's automated totals is outlined at FAQ767-6524.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top