SQL Rev 2
SQL Rev 2
+--------------------+
| Database |
+--------------------+
| company |
| guggu |
| hui |
| info |
| infopract |
| information_schema |
| ipttn |
| jmj |
| kappa |
| mysql |
| office |
| office2 |
| performance_schema |
| sani |
| sarneet |
| savi |
| school |
| school55 |
| sys |
| tution |
| vanshika |
| yuvraj |
+--------------------+
22 rows in set (0.01 sec)
mysql> update e set dept = ' finance' where eid=104 and eid=105;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> update e set dept = ' finance' where eid=104 and eid=105;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql>
mysql>
mysql> SELECT * FROM E WHERE SALARY BETWEEN 50000 AND 80000;
+-----+------------+----------+---------+------------+
| eid | ename | salary | dept | doj |
+-----+------------+----------+---------+------------+
| 101 | john smith | 57200.00 | HR | 2023-01-01 |
| 102 | Lisa Roy | 68200.00 | Finance | 2022-06-15 |
+-----+------------+----------+---------+------------+
2 rows in set (0.00 sec)
mysql> SELECT
-> eid,
-> ename,
-> salary - AVG(salary) OVER() AS AvgCompare,
-> CASE
-> WHEN salary >= AVG(salary) OVER() THEN 'HIGH'
->
-> ELSE 'LOW'
-> END AS SalaryStatus
-> FROM emplt;
+-----+--------------+---------------+--------------+
| eid | ename | AvgCompare | SalaryStatus |
+-----+--------------+---------------+--------------+
| 101 | john smith | -13880.000000 | LOW |
| 102 | Lisa Roy | -2880.000000 | LOW |
| 103 | Ransom Ron | 23920.000000 | HIGH |
| 104 | Harish Hiron | 14920.000000 | HIGH |
| 105 | Bari Brown | -22080.000000 | LOW |
| 106 | ravi kumar | NULL | LOW |
+-----+--------------+---------------+--------------+
6 rows in set (0.01 sec)
mysql> SELECT eid,ename case when salary>= AVG(slary) over() then 'high' else 'low'
end as salarystatus;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'case
when salary>= AVG(slary) over() then 'high' else 'low' end as salarystatus' at line
1
mysql> SELECT eid,ename case when salary>= AVG(slary) over() then 'high' else 'low'
end as salarystatus;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'case
when salary>= AVG(slary) over() then 'high' else 'low' end as salarystatus' at line
1
mysql> SELECT eid,ename ;
ERROR 1054 (42S22): Unknown column 'eid' in 'field list'
mysql> SELECT eid,ename
-> case
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'case' at
line 2
mysql> select date,eid as 'ddtype';
ERROR 1054 (42S22): Unknown column 'date' in 'field list'
mysql> select doj,eid as 'ddtype';
ERROR 1054 (42S22): Unknown column 'doj' in 'field list'
mysql> select doj,eid as 'ddtype' from emplt;
+------------+--------+
| doj | ddtype |
+------------+--------+
| 2023-01-01 | 101 |
| 2022-06-15 | 102 |
| 2020-09-12 | 103 |
| 2019-06-19 | 104 |
| 2021-09-29 | 105 |
| 2023-10-29 | 106 |
+------------+--------+
6 rows in set (0.00 sec)