Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with SQL!!!

Status
Not open for further replies.

request

Programmer
Dec 5, 2001
76
US
I am creating a Crystal report where the stored procedure will be used.

In my stored procedure there will be 2 tables used -> EMPLOYEE and TIME

In my report I have to display the records as follows:

Employee Time


Now, all the employees will not have the time entered. In other words, all the employees
in the employee table may not have a record in the TIME table.

What will be the best way to code the SQL in the stored procedure so that I get all the
employees from the employee table and the employees with their time info from the TIME table.

I want my records to look as follows:

Employee Time
E1
E2 3
E3 6
E4
E5 8

instead of

Employee Time
E1
E2
E2 3
E3
E3 6
E4
E5
E5 8

ANy help will be greatly appreciated.

Thanks
 
You need OUTER JOIN.

SELECT EMP.*, TIME.*
FROM EMP, TIME
WHERE TIME.EMP_ID(+)=EMP.ID

Regards, Dima
 
It would be better if we can see your select statement.
 
Copy paste your select statement we have a look at it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top