Consider the following:
What will be the output of the following SELECT statement?
SELECT SUM(price1) AS total1, SUM(price2) AS total2 FROM item HAVING total1 = total2
A.
Option A
B.
Option B
C.
Option C
Consider the following:
What will be the output of the following SELECT statement?
SELECT SUM(price1) AS total1, SUM(price2) AS total2 FROM item HAVING total1 = total2
A.
Option A
B.
Option B
C.
Option C
well i have MySQL Server 5.5.28
on my localhost it shows that the answer is A.
I create the exact table and inserted the same values.
[source]
mysql> desc item;
+——–+————–+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+——–+————–+——+—–+———+——-+
| name | varchar(30) | YES | | NULL | |
| price1 | float(10,2) | YES | | NULL | |
| price2 | double(10,2) | YES | | NULL | |
+——–+————–+——+—–+———+——-+
3 rows in set (0.01 sec)
mysql> select * from item;
+——-+——–+——–+
| name | price1 | price2 |
+——-+——–+——–+
| item1 | 10.10 | 10.10 |
| item2 | 4.90 | 4.90 |
+——-+——–+——–+
2 rows in set (0.00 sec)
mysql> SELECT SUM(price1) AS total1, SUM(price2) AS total2 FROM item HAVING total1 = total2;
+——–+——–+
| total1 | total2 |
+——–+——–+
| 15.00 | 15.00 |
+——–+——–+
1 row in set (0.00 sec)
[/source]
Thanks 🙂