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 / newbie

SELECT MAX(E.Salary) FROM
(SELECT MAX(Salary) SalaryFROM dep1
UNION
SELECT MAX(Salary) Salary FROM dep2) E

Is This Answer Correct ?    36 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does select 1 mean?

534


What is ssrs?

99


What is shared lock?

495


Explain what is public role in sql server?

584


Explain cdc and sql injection?

549






Explain full-text indexing?

518


What is db stored procedure?

469


Who developed sql server?

534


Do you know the cursor optimization tips?

590


Which data type columns are the best candidates for full-text indexing?

604


What is truncate table?

550


What is the definition for sql server 2000?

598


What are the lambda triggers?

489


What are the transaction properties?

558


How do I view a procedure in sql server?

541