Like this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.13

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

umysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> create table time_daily (project_id int(3) primary key auto_increment, time_worked int(3), user_id varchar(3), period_id varchar(3));
Query OK, 0 rows affected (0.06 sec)


mysql> insert into time_daily (null, 3, 'clh', '27');
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'null, 3, 'clh', '27')' at line 1
mysql> insert into time_daily (time_worked, user_id, period_id) values (3, 'clh', '27');
Query OK, 1 row affected (0.52 sec)


mysql> insert into time_daily (time_worked, user_id, period_id) values (0, 'clh', '27');
Query OK, 1 row affected (0.00 sec)


mysql> insert into time_daily (time_worked, user_id, period_id) values (5, 'clh', '27');
Query OK, 1 row affected (0.00 sec)


mysql> SELECT project_id, SUM(time_worked) AS total FROM time_daily WHERE user_id='clh' AND period_id='27' GROUP BY project_id HAVING total>0
-> ;
+------------+-------+
| project_id | total |
+------------+-------+
| 1 | 3 |
| 3 | 5 |
+------------+-------+
2 rows in set (0.18 sec)



Douglas Sims wrote:


Would something like this do what you want?

SELECT project_id, SUM(time_worked) AS total FROM time_daily WHERE user_id='clh' AND period_id='27' GROUP BY project_id HAVING total>0;



Cory Hicks wrote:

Hello,

I must be having a goober moment.....I am running the following sql
query with no problems:

SELECT project_id,
IF (SUM( time_worked ) > '0.00', SUM( time_worked ),'NULL') AS total
FROM time_daily
WHERE user_id = 'clh' AND period_id = '27'
GROUP BY project_id
However, having 'NULL' appear where the total is 0.00 doesn't do me much
good :-) How do I write this query to only show me the results where the
total is > 0.00...so where the results that total 0.00 don't appear at
all.

I am sure I am missing something...thanks for any help!

Cory








-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to