I'm having some trouble getting a query involving SUM() to work. It refuses to work no matter what I try.
mysql> describe TRANSACTION;
+-------------------+-------------+------+-----+------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+------------+----------------+
| id | int(11) | | PRI | 0 | auto_increment |
| date | date | | | 0000-00-00 | |
| agent_id | tinyint(4) | | | 0 | |
| resort_id | smallint(6) | | | 0 | |
| request_source_id | int(1) | | | 0 | |
| amount | smallint(6) | | | 0 | |
+-------------------+-------------+------+-----+------------+----------------+
6 rows in set (0.05 sec)
mysql> select SUM(amount) FROM TRANSACTION;
+-------------+
| SUM(amount) |
+-------------+
| 0 |
+-------------+
1 row in set (0.03 sec)
mysql> select SUM(amount) FROM TRANSACTION GROUP BY resort_id;
+-------------+
| SUM(amount) |
+-------------+
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
+-------------+
5 rows in set (0.04 sec)
mysql> SELECT VERSION();
+-----------+
| version() |
+-----------+
| 3.22.21 |
+-----------+
1 row in set (0.03 sec)
As you can see, all sums result in 0 when they DEFINITELY are not. I have the same problem using MAX(), MIN(), and AVG(), but not with COUNT().
Any ideas? This is ridiculous.
mysql> describe TRANSACTION;
+-------------------+-------------+------+-----+------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+------------+----------------+
| id | int(11) | | PRI | 0 | auto_increment |
| date | date | | | 0000-00-00 | |
| agent_id | tinyint(4) | | | 0 | |
| resort_id | smallint(6) | | | 0 | |
| request_source_id | int(1) | | | 0 | |
| amount | smallint(6) | | | 0 | |
+-------------------+-------------+------+-----+------------+----------------+
6 rows in set (0.05 sec)
mysql> select SUM(amount) FROM TRANSACTION;
+-------------+
| SUM(amount) |
+-------------+
| 0 |
+-------------+
1 row in set (0.03 sec)
mysql> select SUM(amount) FROM TRANSACTION GROUP BY resort_id;
+-------------+
| SUM(amount) |
+-------------+
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
+-------------+
5 rows in set (0.04 sec)
mysql> SELECT VERSION();
+-----------+
| version() |
+-----------+
| 3.22.21 |
+-----------+
1 row in set (0.03 sec)
As you can see, all sums result in 0 when they DEFINITELY are not. I have the same problem using MAX(), MIN(), and AVG(), but not with COUNT().
Any ideas? This is ridiculous.