Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
select sum( col1 ) as col2
, sum( col3 ) as col4
, ( sum( col1 ) + sum( col3 ) ) / sum( col1 ) as answer
from table
foxtrot(~)$ date
Wed Apr 13 22:19:37 MDT 2005
foxtrot(~)$ mysql -p -h s1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8037 to server version: 4.0.17-standard-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database test;
ERROR 1007 (00000): Can't create database 'test'. Database exists
mysql> create table sums ( col1 integer, col2 integer );
ERROR 1046 (00000): No Database Selected
mysql> use test;
Database changed
mysql> create table sums ( col1 integer, col2 integer );
Query OK, 0 rows affected (0.12 sec)
mysql> insert into sums values ( 1, 2 );
Query OK, 1 row affected (0.06 sec)
mysql> insert into sums values ( 3, 4 );
Query OK, 1 row affected (0.06 sec)
mysql> insert into sums values ( 5, 6 );
Query OK, 1 row affected (0.05 sec)
mysql> select sum( col1 ), sum( col2 ) from sums;
+-------------+-------------+
| sum( col1 ) | sum( col2 ) |
+-------------+-------------+
| 9 | 12 |
+-------------+-------------+
1 row in set (0.06 sec)
mysql> select sum( col1 ) as sum1, sum( col2 ) as sum2 from sums;
+------+------+
| sum1 | sum2 |
+------+------+
| 9 | 12 |
+------+------+
1 row in set (0.05 sec)
mysql> select sum( col1 ) as sum1, sum( col2 ) as sum2, sum1 + sum2 from sums;
[solution left as an exercise to the student]
mysql> exit;
Bye
foxtrot(~)$ date
Wed Apr 13 22:22:22 MDT 2005
foxtrot(~)$