473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1783
"Wire" <wi*****@zonnet .nl> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
517
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 fields, even though they are related to the "name", differs from row to row ( they are things like the address etc, which could have changed on the next entry for the same "name")
7
1692
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 Stations Station_Titles ------ -------- ------------- id id Station_ID Title StationName Title_ID
6
6904
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 query where I have to get result of the all counts for every hour of the date range. Something like that: from starting hour to final hour = total row count (if there is an entries), from 01:00 to 02:00 = 5,
48
3884
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 query of all students in both tables with no duplicates. No clue whatsoever.
4
1236
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... ---------------------------------------------------------------------- $db1 = mysql_connect("something.com", "username", "pass") or die("Could not connect."); if(!$db1)
0
2460
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 the whole. I really need MySQL wizz to give me a hand (and maybe refer me to books to get me to the wizz level myself). First off, english is a second language to me and sometimes my sentences might be a little awkward. Please forgive me. Mon...
0
5578
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
9
1618
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 is a perfectly legal address and I don't want to disallow it, because I use this style myself and find it useful. For example user+whatever@gmail.com will get delivered to user@gmail.com. Now, the user forgets his password. He is prompted to...
5
1435
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... for example: id name slat slon elat elon dist 1 65 -10.32 136.64 -10.18 136.69 6556.52 2 65 -10.18 136.69 -10.16 136.72 1701.68
1
2277
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
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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
10376
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...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7661
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
6881
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
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.