Hello, and thanks for the reply.
I dont' know PHP, but I can understand that you are suggesting to "manually"
iterate the records to find the events, and group them by day. Is this right?
"C.Peachment" <[EMAIL PROTECTED]> ha scritto: What is wrong with using:
select EventID, EventDate, EventTime
order by EventDate, EventTime
group by EventDate;
You have a separate display problem - you want
to put up to three records on the same line. This is
a language and application specific problem. In PHP,
using the PDO module and producing output for a
web page, it can be solved with something like:
$SqlText = "select EventID, EventDate, EventTime " .
" order by EventDate, EventTime " .
" group by EventDate";
$Stmt = $dbh->prepare($SqlText);
$Stmt->execute();
$Found = false;
$PriorDate = 0;
while ($Row = $Stmt->fetch(PDO::FETCH_OBJ)) {
$Found = true;
if ($Row->EventDate != $PriorDate) {
if ($PriorDate != 0) {
echo "
\n";
}
echo "$Row->EventID, $Row->EventDate";
}
echo "$Row->EventTime";
$PriorDate = $Row->EventDate;
if ($Found) {
echo "
\n"; // close off last output statement
$Stmt->closeCursor();
On Mon, 10 Jul 2006 11:45:24 +0200 (CEST), [EMAIL PROTECTED] wrote:
>Hello, everybody
>I have the following problem: I have a table that contains "Events", with the
>related date and time:
>Fields:
>EventID
>EventDate
>EventTime
>I would like to "group" these records by day, returning all the "times" of the
>events, like:
>EventID, EventDate, EventTime1, EventTime2, EventTime3
>(I can assume that no more than 3 events happen on the same day).
>I did this query:
>SELECT T1.EventDate, T1.EventTime AS Time1, T2.EventTime AS Time2
>FROM Events AS T1 LEFT JOIN Events AS T2 ON T2.EventDate = T1.EventDate AND
>T2.EventTime > T1.EventTime;
>This query "works", but it has the following problems:
>1. it returns several times the same "record" (can't understand why)
>2. it takes about 30 seconds (!!) to run, and it consumes all the physical
>memory of the system...
>Any help on this?
>Thanks in advance for any reply.
>Kind regards
>Marco
> Chiacchiera con i tuoi amici in tempo reale!
> http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com