If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Help with HOUR() query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-01-05, 16:51
Atari Atari is offline
Registered User
 
Join Date: Nov 2004
Posts: 35
Question Help with HOUR() query

Hello,

I have a quick question.

In mySQL you can do the following, where messages.date is a datetime column:

Code:
SELECT HOUR( date ) AS time FROM messages;
I would like to select all columns from messages, where HOUR( date ) = 1 for example. How do I do this? Also, how would I issue a count?

ex in english:

"Select the column count AS total FROM messages WHERE HOUR( messages.date ) is 1"

Thanks in advance for your help.
Alexandre
Reply With Quote
  #2 (permalink)  
Old 03-02-05, 06:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by Atari
I would like to select all columns from messages, where HOUR( date ) = 1 for example. How do I do this? Also, how would I issue a count?
what do you mean by "issue a count"? you mean a count of the number of rows that have the hour equal to 1? that would give you a one-row answer, and you can't get that at the same time as the columns
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On