0
我试图让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
联接是一个伟大的想法,但我们需要的条件来获取正确的启动时间,其中部门= 10,11,12或dbo.employeerole.name ='质量控制','生产','销售','管理' – 2011-12-22 20:56:53
您可以将这些标准添加到您的where子句;-) – ChristopherS 2011-12-22 21:09:10