Questions tagged [top-n]
322 questions
-2
votes
4 answers
The 'min' and 'max' does not work with other information
I am trying to work out the min and max price on a table of items:
item [itemcode] [itemname] [iteminfo] [price]
I want to get not only the min and max price but also what the item is:
so query result needs to be cheapest item, itemname item info,…

Admiral Diggs
- 1
- 2
-3
votes
2 answers
Selecting a nth row from a table using SQL in Oracle, MYSQL and SQL Server assuming there is no ordered column in the table
Let us take a table t1
SQL > Select * from t1;
COL1
9
1
8
6
4
Q) Query to retrieve third row from the table.
A) Oracle :
SQL > select col1 from (select col1, row_number() over(order by rowid) rn from t1) where rn=3;
As…

rama krishna
- 21
- 2
-3
votes
1 answer
How to get max salary of 2 employees in each department
How to get max salary of 2 employees in each department in which employee is associated with?

Shivani Gauryan
- 103
- 2
- 12
-3
votes
2 answers
Get the minimum employees with a given job
I have this table:
Name Null? Type
-------------------------- -------- ------------
EMPLOYEENO NOT NULL NUMBER(4)
ENAME VARCHAR2(15)
JOB …

Chirila Vasile
- 359
- 1
- 2
- 11
-4
votes
1 answer
Oracle find manager salary and his/her employee with maximum salary
I have task to write but after thinking on it for a long time unfortunately I cant solve it. I have to find manager salary and his/her employee with highest salary. Also I must include employee last name and what percent is his her/salary to…
-5
votes
2 answers
i am getting the error ORA-00979. Point out the error
SELECT department_name, cou FROM
(
SELECT department_name, count(student_id) AS cou
FROM department d NATURAL JOIN student s
GROUP BY department_name
)
GROUP BY department_name HAVING cou=max(cou);

sheshin
- 101
- 1
-7
votes
1 answer
SQL - How to select a row having a column with max value without using sub query in Oracle
date value
18/5/2010 40
18/5/2010 20
20/5/2010 60
18/5/2010 30
17/5/2010 10
16/5/2010 40
18/5/2010 60
18/5/2010 25
Output
date …

mayank
- 25
- 1
- 5