Count amount of weeks someone was paid in SQL
I'm using sql server 2005 and want to know if there is a way to query the number of weeks a person got paid? I need to check if the person was paid first, and then see wether they were taxed with a particular tax on that pay date, and if so count that as a week worked. This is what I have so far, but it is flawed . I need to some how first get all the weeks the person got paid and then in those weeks if the tax no was "AAAA" count it as a week worked. SET @SQL = @SQL + @CR + N'SUM(case when payTax.TaxNo =''AAAAA' ' SET @SQL = @SQL + @CR + N' and BM.Adjustment <> ''A''' SET @SQL = @SQL + @CR + N' AND pay.Method <> ''MANUAL'' AND PAYTAX.TAXES <> 0 ' SET @SQL = @SQL + @CR + N' then dbo.fn_PayCycleNumOfChecks(pay.PayCycle) else 0 end) as WorkWeeks ' Any help?
January 25th, 2011 2:29am

Ok, please post sample data + an expected result I will try helo you out Please always state what vesrion you are usingBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
January 25th, 2011 2:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics