Я пытаюсь сделать выбор из 2 разных таблиц, что приводит к выводу, подобному этому:
Punchdate | EmployeeCode | Name | Punch_in | Break | Lunch | Second_start | Break | Punch out
---------------------------------------------------------------------------------------------
11.08.2005 1021 John Smith 7:00 9:00 12:00 1:00 3:10 4:30
dbo.Punchintervals
employee(dbo.punchintervals.employee=dbo.employee.objid)
intime
outime
department/*(dbo.punchintervals.department = dbo.emprole.objid*/
/*(intime column has all the punches form all the departments,they need to be sorted trough the department column)*/
dbo.employee
employee/*(dbo.employee.objid=dbo.punchinterval.employee)*/
name
code
dbo.emprole
objid/*objid is just a vule example 10 (dbo.emprole.objid = dbo.punchinterval.department)*/
name/*(name of the role example: quality control, punch out, lunch,break)*/
пока это была моя последняя попытка
SELECT TOP (100)
PUNCHDATE,CODE,name
,(
SELECT [sitewatch].[dbo].Punchinterval.INTIME
FROM [sitewatch].[dbo].Punchinterval AS PunchIn
WHERE [sitewatch].[dbo].Punchinterval.DEPARTMENT = '10'
) AS Startime
,(
SELECT [sitewatch].[dbo].Punchinterval.INTIME
FROM [sitewatch].[dbo].Punchinterval AS PunchIn
WHERE [sitewatch].[dbo].Punchinterval.DEPARTMENT = '11'
) AS break2
FROM [sitewatch].[dbo].Punchinterval,[sitewatch].[dbo].employee