473,383 Members | 1,795 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,383 software developers and data experts.

Help me with group by query in MYSQL 3.x

Hello experts,

I have a little group by problem, hope you can help me.
I have a lot off records which I want to group by "HOUR(timefield)"

example:

01-02-2005 13:28:00 25.0
01-02-2005 13:11:01 24.0
01-02-2004 13:10:03 23.5
01-01-2005 12:08:00 25.0
01-01-2005 12:01:01 24.0
01-01-2004 12:00:03 23.5

I want to group them by HOUR(timefield) if I do this I get the first
record of all the groups
result below:
01-02-2004 13:10:03 23.5
01-01-2004 12:00:03 23.5

However I want the last records of each group
result I want:
01-02-2005 13:28:00 25.0
01-01-2005 12:08:00 25.0

Who can help me on this
thanks guys
Regards
Pieter

Dec 11 '05 #1
3 1763
"Wire" <wi*****@zonnet.nl> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I have a little group by problem, hope you can help me.
I have a lot off records which I want to group by "HOUR(timefield)"
However I want the last records of each group


See the thread "problem with nested select" a couple of days ago on this
newsgroup. Your problem is equivalent to the one in that thread.

Regards,
Bill K.
Dec 12 '05 #2
Hi Bill

I saw the thread
but I think that is not my problem
Please help

Dec 12 '05 #3
Wire wrote:
I have a little group by problem, hope you can help me.
I have a lot off records which I want to group by "HOUR(timefield)"


You need to join the table with itself to gain the results you wish.
Examples can be found from the comments in this page (subquery examples
won't work with 3.x, so don't bother trying those).

http://dev.mysql.com/doc/refman/5.0/...group-row.html
Dec 12 '05 #4

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

Similar topics

0
by: Petre Agenbag | last post by:
Hi List Can anyone help me to do the following without the need of subselects: I have a table that contains rows where mostly, the only common field is the "name". The rest of the data...
7
by: Jim | last post by:
I need help on a query. There is a common titles database for several radio stations Some titles are enabled and some are not enabled for each station. Example of some tables: Titles ...
6
by: Ljoha | last post by:
I need to create report where will be shown total quantity of all rows for every hour in some data range. I have a table where I have column in DATETIME format. I have problem to create sql...
48
by: phillip.s.powell | last post by:
MySQL 3.23.58 - 4.0.17 (yep, several database server instances, don't ask) I have database Spring with table Students I have database Summer with table Students I am tasked to produce a...
4
by: Dejan | last post by:
hy I have two mysql servers. One is on my local comp (localhost) and the other is something.com Creating simple php script to do this... ...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
9
by: axlq | last post by:
I'm trying to figure out a MySQL query expression to match an email address. Here's the situation: User registers on my site with a "plus style" email address (username+key@example.com). This...
5
by: inexion | last post by:
Hello, I'll try to explain what I'm trying to accomplish here, hopefully not too bad a task. Basically I have an existing table with data that will be operated on to form new records etc... ...
1
by: chienee | last post by:
here is the code <?php session_cache_limiter('private,must-revalidate'); session_start(); require_once("config.php"); include ("classes/db_functions.php"); include ("classes/display.php");
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.