Hi,
I have a table A which has four rows as follows
Table A
-------
empname salary
------- ------
A 1000
B 2000
C 3000
A 1000
B 2000
D 5000
I need the following output:
empname salary
------- ------
A 1000
A 1000
B 2000
B 2000
Thanks in advance
Answers were Sorted based on User's Feedback
Answer / mohit kumar singhal
Select emp.empname, emp.salary from emp right outer join (
select empname, salary from emp
group by empname, salary
having count(empname) > 1) as tbl
on emp.empname = tbl.empname
| Is This Answer Correct ? | 8 Yes | 3 No |
Answer / murtaza
select empname,salary from A
where empname IN ('A','B');
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / enis ertem
Select emp.empname, emp.salary from employee emp join (
select empname, salary from employee emp
group by empname, salary
having count(empname) > 1) as tbl
on emp.empname = tbl.empname
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / zaheer abbas
select empname ,salary
from A
where salary <= 2000
order by empname
| Is This Answer Correct ? | 6 Yes | 6 No |
Answer / rajkumar
select*from emp where empname in ('A','B') order by empname
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / vinay
select empname , salary
from A
where empname in (select name from A group by empname
having count(empname ) > 1)
order by empname
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / anand
select empname,salary from tableA where(empname in (select
empname from tableA group by empname having count(empname)
>1))order by empname
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / kuntal
select * from A where empname in (select empname from A
group by empname having COUNT(*)>1)
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / goutam dey
select empname,salary from tableA
groupby empname
having count(empname)>1
| Is This Answer Correct ? | 3 Yes | 7 No |
Answer / inderpal
Select empname, salary from A order by empname
| Is This Answer Correct ? | 1 Yes | 5 No |
What are the different types of joins and what does each do?
How to select all columns of all rows from a table with a select statement in ms sql server?
How to display a past time in days, hours and minutes?
What will be the value of @@fetch_status if a row that was a part of the cursor resultset has been deleted from the database after the time the stored procedure that opened the cursor was executed?
two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd table EmpSal has 2 columns ID and Salary Contains data -1,1000 2,5000 3,3000 Find name of employee having maximum salary ?
Insert syudents details in table.Current system date &time insert into joining time.How do insert?( in sysdate only return current system date how do add time?)
What is store procedure? When do you use?
What does the on delete cascade option do?
How can i change the column name.
13 Answers HCL, Yardi Software,
If a stored procedure is taking a table data type, how it looks?
What are the differences between left join and inner join in sql server?
How sql server executes a statement with nested subqueries?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)