how to get the maximum among two tables,for example table 1
(dep1) have (emp_id,emp_name,salary) columns and table 2
(dept2) have (emp_id,emp_name,salary) columns,i want which
employee have the maximum salary among two tables?
Answer Posted / praveend
Try this. I have tried it.
Select id, name, Max(salary) as salary from
(Select id, name, salary from emp where salary = (Select
Max(salary) from emp)
Union
Select id, name, salary from emp1 where salary = (Select
Max(salary)from emp1)) as B
where salary = (
Select Max(salary) as salary from
(Select id, name, salary from emp where salary = (Select
Max(salary) from emp)
Union
Select id, name, salary from emp1 where salary = (Select
Max(salary)from emp1)) as C
)
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
can you instantiate a com object by using t-sql? : Sql server database administration
Explain what is the difference between a local and a global temporary table?
What is the simplest way to create a new database in ms sql server?
What is implicit cursors?
What do you understand by physical_only option in dbcc checkdb?
How to create a simple user defined function in ms sql server?
Mention the differences between local and global temporary tables.
Do you know how to send email from database?
How do I run a trace in sql server?
How to connect to SQL Azure Database by using sqlcmd?
How to get a list of columns in a view using the "sp_columns" stored procedure?
What do you understand by the analysis services in sql server?
How to create a view using data from another view?
What have included columns when we talk about sql server indexing?
role of sql sever 2005 in database rather than any other database