Home > database >  Oracle database query to a big help solve, thank you very much
Oracle database query to a big help solve, thank you very much

Time:09-16

Query to remove the name contains K employees, number of employees more than 3 a variety of work, in descending order work, this statement I wrote the select * from emp where ename & lt;> The from '% K % K (select job, count (*) from emp group by job having the count (*) & gt; 3); This is where I went wrong???

CodePudding user response:

Wrong SQL syntax

First of all, ename & lt;> '% K %' is not right to write, fuzzy query to use LIKE, should be changed to ename not LIKE '% K %'
Second to use and or or between two query conditions,
You write the ename & lt;> The from '% K % K (select job, count (*) from emp group by job having the count (*) & gt; 3) all wrong
It should be
Where ename not like '% K %'
And the job in (select job
The from (select job, count (*) from emp group by job having the count (*) & gt; 3))
No sorting again

A complete written
Select * from emp
Where ename not like '% K %'
And the job in (select job
The from (select job, count (*)
The from emp
Group by job
Having the count (*) & gt; 3))
The order by job desc

Suggest a good play on base

CodePudding user response:

Pay attention to the "after", should be excluded name contains K employees

CodePudding user response:

reference 1st floor yaiger response:
wrong SQL syntax

First of all, ename & lt;> '% K %' is not right to write, fuzzy query to use LIKE, should be changed to ename not LIKE '% K %'
Second to use and or or between two query conditions,
You write the ename & lt;> The from '% K % K (select job, count (*) from emp group by job having the count (*) & gt; 3) all wrong
It should be
Where ename not like '% K %'
And the job in (select job
The from (select job, count (*) from emp group by job having the count (*) & gt; 3))
No sorting again

A complete written
Select * from emp
Where ename not like '% K %'
And the job in (select job
The from (select job, count (*)
The from emp
Group by job
Having the count (*) & gt; 3))
The order by job desc

Suggest a good play on basis of
well, thank you already understand
  • Related