Rahul SQL File 18.04.2024
Rahul SQL File 18.04.2024
4291]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Admin>mysql -u root -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.32 MySQL Community Server - GPL
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select sal from emp where sal 800 and 5000;
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 '800 and
5000' at line 1
mysql> select sal from emp where sal between 800 and 5000;
+---------+
| sal |
+---------+
| 800.00 |
| 1600.00 |
| 1250.00 |
| 2975.00 |
| 1250.00 |
| 2850.00 |
| 2450.00 |
| 3000.00 |
| 5000.00 |
| 1500.00 |
| 1100.00 |
| 950.00 |
| 3000.00 |
| 1300.00 |
+---------+
14 rows in set (0.00 sec)
mysql> select sal from emp where sal between 800 and 2000;
+---------+
| sal |
+---------+
| 800.00 |
| 1600.00 |
| 1250.00 |
| 1250.00 |
| 1500.00 |
| 1100.00 |
| 950.00 |
| 1300.00 |
+---------+
8 rows in set (0.00 sec)
mysql> select sal from emp where sal between 800 and 2000 order by sal desc;
+---------+
| sal |
+---------+
| 1600.00 |
| 1500.00 |
| 1300.00 |
| 1250.00 |
| 1250.00 |
| 1100.00 |
| 950.00 |
| 800.00 |
+---------+
8 rows in set (0.00 sec)
mysql> select sal from emp where sal between 800 and 2000 order by sal limit 1,1;
+--------+
| sal |
+--------+
| 950.00 |
+--------+
1 row in set (0.00 sec)
mysql> select sal from emp where sal between 800 and 2000 order by sal desc limit
1,1;
+---------+
| sal |
+---------+
| 1500.00 |
+---------+
1 row in set (0.00 sec)
mysql> select sal from emp where sal 800 and 3000;
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 '800 and
3000' at line 1
mysql> select sal from emp where sal between 800 and 3000 order by sal desc;
+---------+
| sal |
+---------+
| 3000.00 |
| 3000.00 |
| 2975.00 |
| 2850.00 |
| 2450.00 |
| 1600.00 |
| 1500.00 |
| 1300.00 |
| 1250.00 |
| 1250.00 |
| 1100.00 |
| 950.00 |
| 800.00 |
+---------+
13 rows in set (0.00 sec)
mysql> select distinct(sal) from emp where sal between 800 and 3000 order by sal
desc;
+---------+
| sal |
+---------+
| 3000.00 |
| 2975.00 |
| 2850.00 |
| 2450.00 |
| 1600.00 |
| 1500.00 |
| 1300.00 |
| 1250.00 |
| 1100.00 |
| 950.00 |
| 800.00 |
+---------+
11 rows in set (0.00 sec)
mysql> select * from Emp where sal 800 and 1500 group by sal;
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 '800 and
1500 group by sal' at line 1
mysql> select * from Emp where group by sal;
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 'group by
sal' at line 1
mysql> select sal from Emp group by sal;
+---------+
| sal |
+---------+
| 800.00 |
| 1600.00 |
| 1250.00 |
| 2975.00 |
| 2850.00 |
| 2450.00 |
| 3000.00 |
| 5000.00 |
| 1500.00 |
| 1100.00 |
| 950.00 |
| 1300.00 |
+---------+
12 rows in set (0.00 sec)
mysql> select sal from emp where sal 800 and 1600 group by sal;
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 '800 and
1600 group by sal' at line 1
mysql> select sal from Emp where sal between 800 and 1000 group by sal;
+--------+
| sal |
+--------+
| 800.00 |
| 950.00 |
+--------+
2 rows in set (0.00 sec)
mysql> select sal from emp where sal between 800 and 1000 order by sal desc;
+--------+
| sal |
+--------+
| 950.00 |
| 800.00 |
+--------+
2 rows in set (0.00 sec)
mysql> select sal from emp where sal between 800 and 2000 order by sal desc;
+---------+
| sal |
+---------+
| 1600.00 |
| 1500.00 |
| 1300.00 |
| 1250.00 |
| 1250.00 |
| 1100.00 |
| 950.00 |
| 800.00 |
+---------+
8 rows in set (0.00 sec)
mysql> select sal,empno from emp where sal between 800 and 2000 order by sal desc;
+---------+-------+
| sal | empno |
+---------+-------+
| 1600.00 | 7499 |
| 1500.00 | 7844 |
| 1300.00 | 7934 |
| 1250.00 | 7521 |
| 1250.00 | 7654 |
| 1100.00 | 7876 |
| 950.00 | 7900 |
| 800.00 | 7369 |
+---------+-------+
8 rows in set (0.00 sec)
mysql> select sal,empno,ename from emp where sal between 800 and 2000 order by sal
desc;
+---------+-------+--------+
| sal | empno | ename |
+---------+-------+--------+
| 1600.00 | 7499 | ALLEN |
| 1500.00 | 7844 | TURNER |
| 1300.00 | 7934 | MILLER |
| 1250.00 | 7521 | WARD |
| 1250.00 | 7654 | MARTIN |
| 1100.00 | 7876 | ADAMS |
| 950.00 | 7900 | JAMES |
| 800.00 | 7369 | SMITH |
+---------+-------+--------+
8 rows in set (0.00 sec)
mysql> select count(), sal ,job from emp where sal between 800 and 3000 group by
sal;
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 '),
sal ,job from emp where sal between 800 and 3000 group by sal' at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 group by sal;
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
'),sal,job from emp where sal between 800 and 3000 group by sal' at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 group by sal,
job having count()>1;
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
'),sal,job from emp where sal between 800 and 3000 group by sal, job having count'
at line 1
mysql> use classwork_db;
Database changed
mysql> select count(),sal,job from emp where sal between 800 and 3000 group by sal,
job having count()>1;
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
'),sal,job from emp where sal between 800 and 3000 group by sal, job having count'
at line 1
mysql> select count(*),sal,job from emp where sal between 800 and 3000 group by
sal, job having count()>1;
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 ')>1' at
line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 group by sal,
job having count()>1;
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
'),sal,job from emp where sal between 800 and 3000 group by sal, job having count'
at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 groupby
sal,job having count();
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
'),sal,job from emp where sal between 800 and 3000 groupby sal,job having count()'
at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 groupby
sal,job havingcount();
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
'),sal,job from emp where sal between 800 and 3000 groupby sal,job havingcount()'
at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 groupby
sal,job having count()>1;
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
'),sal,job from emp where sal between 800 and 3000 groupby sal,job having count()'
at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 groupby
sal,job havingcount()>1;
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
'),sal,job from emp where sal between 800 and 3000 groupby sal,job havingcount()>'
at line 1
mysql> select count(),sal,job from emp where sal between 800 and 3000 group by
sal,job having count()>1;
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
'),sal,job from emp where sal between 800 and 3000 group by sal,job having count('
at line 1
mysql> select count()sal,job from emp where sal between 800 and 3000 group by
sal,job having count()>1;
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 ')sal,job
from emp where sal between 800 and 3000 group by sal,job having count()' at line 1
mysql> select * from emp ;
+-------+--------+-----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hire | sal | comm | deptno |
+-------+--------+-----------+------+------------+---------+---------+--------+
| 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 |
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 |
| 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 |
| 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 |
+-------+--------+-----------+------+------------+---------+---------+--------+
14 rows in set (0.00 sec)
mysql> select count(), sal ,job from emp where sal between 800 and 3000 group by
sal, job having count()>1;
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 '),
sal ,job from emp where sal between 800 and 3000 group by sal, job having cou' at
line 1
mysql> select count(sal), sal ,job from emp where sal between 800 and 3000 group by
sal;
ERROR 1055 (42000): Expression #3 of SELECT list is not in GROUP BY clause and
contains nonaggregated column 'classwork_db.emp.job' which is not functionally
dependent on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_by
mysql> select count(sal),job from emp where sal between 800 and 3000 group by sal;
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and
contains nonaggregated column 'classwork_db.emp.job' which is not functionally
dependent on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_by
mysql> select count(sal),job from emp where sal between 800 and 3000 group by sal;