Sunday, October 12, 2008

Select Distinct, Not In and Right Outer Join in SQL Command

Programming

Hi, Today management asked me to get quick data absent every day for the employee who did not enter or his data did not enter the absent machine, then I tried to modify the program absent that I created and put the SQL command as follows:
Ex :
Table1
Id_numbernameDepartment
A0001DavidFinance
A0002RahulFinance
A0003RobertFinance
B0001DianaFinance
B0002FabioFinance
B0003BudiFinance
Table2
Id_numberDate
A000109/14/2008
A000209/14/2008
A000309/15/2008
B000109/15/2008
B000209/15/2008
B000309/15/2008
To get the result use this SQL command below:
SELECT DISTINCT (dbo. Table2.kode), dbo. Table1.kode, dbo. Table1.nama, dbo. Table1.department FROM dbo. Table2 RIGHT OUTER JOIN dbo. Table1 ON dbo. Table2.kode = dbo. Table1.kode'Where dbo. Table1.kode NOT IN (select dbo. Table2.kode from dbo.Table2 WHERE tanggal = ‘09/15/2008) and dbo. Table1.department = ‘Finance’


Related Topics:
How to connect Delphi to database SQL Server
Select Distinct, Not In and Right Outer Join in SQL Command
How To Import Data Excel To SQL Server 2005
Function Date and Time in Foxpro

No comments:

Post a Comment