Thanks for the replies, Lucas, Terence, and John!

John: I don't run Windows, so that will not help.

Terence: No. I wanted the sums of all of the firsts...Lucas nailed it,
but...

Lucas: If I enter "SELECT SUM(first) FROM example;" it gives me the correct
answer, 3. I created that simple database because I could not get it to work
on the real one. I found a place online that said to use the command you
said to use, but when I use it on my real data, it gives me an error
message:

ERROR 1140: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP
columns is illegal if there is no GROUP BY clause

..which is why I appended the GROUP BY to the example.

My original statement for the real data looked something like this:

SELECT column5, SUM(column5) FROM realdata WHERE processdate > "2002-8-31"
AND column3 = "done" AND url REGEXP "mysql";

Thus, I get the 1140 error. So, I add the GROUP BY and I get the same kind
of printout I get in my example database, i.e., not a sum of all of the
firsts. What I do want is a sum of all of the numbers in column 5 where the
date is after a certain date, column 3 has "done" in it, and the url matches
a regular expression mysql.

How do I do that?

Thanks!

--kevin

***MY ORIGINAL EMAIL FOLLOWS***
mysql> select * from example;
+-------+--------+
| first | second |
+-------+--------+
| 1     | 2      |
| 2     | 3      |
+-------+--------+
2 rows in set (0.00 sec)

mysql> select first, second, SUM(first) from example group by first;
+-------+--------+------------+
| first | second | SUM(first) |
+-------+--------+------------+
| 1     | 2      |          1 |
| 2     | 3      |          2 |
+-------+--------+------------+
2 rows in set (0.00 sec)


If it is not obvious, I want the sum of "first," which, by my calculations,
should be 3. What am I doing wrong?


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to