mysql> show tables;
+----------------------+
| Tables_in_ricardohDB |
+----------------------+
| Customer |
| FavoriteThings |
| Orders |
| SalesPerson |
| phoneBook |
+----------------------+
5 rows in set (0.04 sec)
mysql> select MAX(age) AS
-> age FROM SalesPerson;
+------+
| age |
+------+
| 63 |
+------+
1 row in set (0.00 sec)
mysql> SELECT age, salary FROM SalesPerson;
+------+--------+
| age | salary |
+------+--------+
| 63 | 120000 |
| 38 | 42000 |
| 26 | 36000 |
| 42 | 50000 |
| 59 | 118000 |
| 27 | 34000 |
+------+--------+
6 rows in set (0.01 sec)
mysql> SELECT distinct age, salary FROM SalesPerson;
+------+--------+
| age | salary |
+------+--------+
| 63 | 120000 |
| 38 | 42000 |
| 26 | 36000 |
| 42 | 50000 |
| 59 | 118000 |
| 27 | 34000 |
+------+--------+
6 rows in set (0.00 sec)
mysql> SELECT name FROM SalesPerson WHERE (age < 30);
+-------+
| name |
+-------+
| Jones |
| Kobad |
+-------+
2 rows in set (0.00 sec)
mysql> SELECT name FROM SalesPerson INNER JOIN Orders WHERE(SalesPerson.Name = Orders.SalesPersonName) AND Orders.CustName = "Abernathy Construction";
+--------+
| name |
+--------+
| Zenith |
| Jones |
| Murphy |
+--------+
3 rows in set (0.01 sec)
mysql> SELECT name FROM SalesPerson WHERE (Salary > 49999 AND Salary < 100000);
+--------+
| name |
+--------+
| Murphy |
+--------+
1 row in set (0.00 sec)
mysql> SELECT name from SalesPerson WHERE age BETWEEN 50 AND 59;
+--------+
| name |
+--------+
| Zenith |
+--------+
1 row in set (0.00 sec)
mysql> SELECT name from SalesPerson WHERE age LIKE '5%';
+--------+
| name |
+--------+
| Zenith |
+--------+
1 row in set (0.00 sec)
mysql> SELECT name FROM Customer WHERE city LIKE '%s';
+---------------------+
| name |
+---------------------+
| Tri-City Builders |
| Amalgamated Housing |
+---------------------+
2 rows in set (0.00 sec)
mysql> SELECT DISTINCT name,salary FROM SalesPerson INNER JOIN Orders WHERE(SalesPerson.Name = Orders.SalesPersonName) AND Orders.CustName != "Abernathy Construction" ORDER BY salary DESC;
+-------+--------+
| name | salary |
+-------+--------+
| Abel | 120000 |
| Jones | 36000 |
+-------+--------+
2 rows in set (0.00 sec)
mysql> SELECT table_name, table_rows
-> FROM INFORMATION_SCHEMA.TABLES
-> WHERE table_schema = 'ricardohDB'
-> AND table_name = 'Orders';
+------------+------------+
| table_name | table_rows |
+------------+------------+
| Orders | 7 |
+------------+------------+
1 row in set (0.00 sec)
mysql> SELECT COUNT(SalesPersonName)
-> AS NumeberofOrders FROM Orders
-> ;
+-----------------+
| NumeberofOrders |
+-----------------+
| 7 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT COUNT(DISTINCT SalesPersonName)
-> AS NumeberofOrders FROM Orders;
+-----------------+
| NumeberofOrders |
+-----------------+
| 4 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT AVG(age) FROM SalesPerson;
+----------+
| AVG(age) |
+----------+
| 42.5000 |
+----------+
1 row in set (0.00 sec)
mysql> SELECT name,MAX(age) AS LargestAge FROM SalesPerson;
+------+------------+
| name | LargestAge |
+------+------------+
| Abel | 63 |
+------+------------+
1 row in set (0.00 sec)
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More