Hi
I want to take who are login more then 3 fridays , i have a script but it comes all please find the script
SELECT distinct left(b.Name,2) MachinID,a.nFingerPrintID EmpId,dtpunched
FROM MHIATTEND.dbo.LogInfo a,MHIATTEND.dbo.TerminalInfo b,MHIATTEND.dbo.SubLocation c
WHERE a.nTerminalID=b.nTerminalID and cast(dtpunched as date) >='2014-04-01'
and left(c.SubLocation_id,2) = left(b.Name,2) and a.inout=1
and cast(dtpunched as date) in (
SELECT Fridays = DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), n.num)
FROM (SELECT TOP 366 num = ROW_NUMBER() OVER(ORDER BY a.NAME)-1
FROM dbo.syscolumns a, dbo.syscolumns b) n
WHERE DATENAME(weekday, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), n.num)) = 'Friday'
)
Please find the Result
MachinIDEmpIddtpunchedD1CE8-005 2014-04-18 05:59:44.000
D1D1-0039 2014-04-04 06:02:30.000
D1D1-0039 2014-04-11 05:58:04.000
D1D1-0191 2014-04-11 06:00:50.000
D1D1-0191 2014-04-18 06:02:10.000
D1D1-0310 2014-04-04 05:58:54.000
D1D1-0310 2014-04-11 05:56:22.000
D1D1-0310 2014-04-18 05:54:06.000
D1D1-0310 2014-04-25 05:57:36.000
D1D12-003 2014-04-11 05:56:56.000
D1D12-003 2014-04-25 05:58:36.000
D1D2-0016 2014-04-11 05:50:32.000
D1D2-0016 2014-04-18 06:01:58.000
D1D2-0068 2014-04-11 06:08:36.000
D1D2-0068 2014-04-25 05:59:56.000
D1D2-0080 2014-04-04 06:10:32.000
D1D2-0080 2014-04-11 06:04:16.000
D1D2-0080 2014-04-18 05:58:12.000
D1D2-0080 2014-04-25 06:08:34.000
D1D2-0091 2014-04-18 05:58:28.000
D1D2-0133 2014-04-11 05:57:46.000
D1D2-0133 2014-04-18 05:59:38.000
D1D2-0201 2014-04-04 06:19:40.000
D1D2-0287 2014-04-11 05:58:28.000
D1D2-0287 2014-04-18 05:57:40.000
But i want below result, who are comes more the 3 fridays.
MachinID EmpIddtpunchedD1 D1-03102014-04-04 05:58:54.000
D1 D1-03102014-04-11 05:56:22.000
D1 D1-03102014-04-18 05:54:06.000
D1 D1-03102014-04-25 05:57:36.000
D1 D2-00802014-04-04 06:10:32.000
D1 D2-00802014-04-11 06:04:16.000
D1 D2-00802014-04-18 05:58:12.000
D1 D2-00802014-04-25 06:08:34.000
Thanks
Mohamed Udhuman