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 / veeresh kethari
User CTE:
with Temp as(select max(sal) Sal from Table1
union
select max(sal) sal from Table2)
select top 1 * from Temp order by sal desc
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Why would you call update statistics?
can you implement data mining in SSRS?
What are the restrictions while creating batches in sql server?
can you instantiate a com object by using t-sql? : Sql server database administration
What is delete query?
How do we know if any query is retrieving a large amount of data or very little data?
Explain what is the difference between a local and a global temporary table?
What are three major types of constraints?
What is difference between temp table and cte?
1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?
What do you know about system database? : SQL Server Architecture
Tell me about normalization in DBMS.
When would you use an insert into .. Select option versus an insert into .. Values option? Give an example of each?
What are the different types of sub-queries?
How to drop existing views from a database in ms sql server?