Welcome Guest, Not a member yet? Register   Sign In
count how may records are AM vs. PM
#1

[eluser]new_igniter[/eluser]
Hello,
I have a DB with mysql a standard timestamp in the format of 2008-01-23 11:44:16

Can someone help me with the mysql syntax for counting the number of records with a time in the AM and PM. It could be 2 different queries, but I havent been able to figure it out.
#2

[eluser]Armchair Samurai[/eluser]
I'd do it like this - retrieve two records from the table, the first being AM totals and the second PM:
Code:
SELECT COUNT(*) AS `times`
FROM `foo`
WHERE HOUR(`bar`) < 12
UNION
SELECT COUNT(*)
FROM `foo`
WHERE HOUR(`bar`) >= 12
#3

[eluser]new_igniter[/eluser]
thanks so much!




Theme © iAndrew 2016 - Forum software by © MyBB