Search:     Advanced search
Browse by category:
C/C++   |   Java   |   Oracle/Database   |   SAP   |   ASP .NET   |   Mainframe-DB2   |   Freshers

Q: how to know the days or months or years between two employees in emp table?

Add comment
Views: 500
Votes: 1
Comments: 0

A:
Let us say you want to find the days between the hiredates of two employees with employee no 99 and 345. in that case you can use the following query
select emp1.hiredate - emp2.hiredate
  from emp emp1, emp emp2
 where emp1.eno = 99
   and emp2.eno= 345

if you do not know the employee no but rather the name then

select emp1.hiredate - emp2.hiredate
  from emp emp1, emp emp2
 where emp1.ename = 'ram'
    and emp2.eno= 'shyam'
 

Others in this Category
document What is a table called, if it has neither Cluster nor Non-cluster Index? What is it used for?
document Q: Can a view be updated/inserted/deleted? If Yes under what conditions ?
document What is Service Broker?
document Q: What is CYCLE/NO CYCLE in a Sequence ?
document What is SQL Profiler?
document What is XML Datatype?
document What is a Linked Server?
document What is SQL Server Agent?
document Q: What are the Various Master and Detail Relation ships.
document Q: Emp table had an employee with salary 2000. I issued an update statement to set the salary to 3000. Then I issued a create table statement. However the create table command errored out. I want to rollback the earlier update statement. Can I do that?
» More articles



RSS