Title / Description
Code select u.u_logon_name as UserName, ty.TaxYear as TaxYear, sum(el.item_qty) as Miles from dbo.INS_EXPENSE_LINES el join dbo.INS_EXPENSE_HEADER eh on el.expense_ref = eh.expense_ref join dbo.INS_USERS u on eh.user_id = u.u_logon_name join ( select line_id, case when item_date < cast(cast(year(item_date) as varchar)+'-05-06' as datetime) then year(item_date)-1 else year(item_date) end as TaxYear from dbo.INS_EXPENSE_LINES el join dbo.INS_EXPENSE_TYPES et on el.expense_type = et.g_id where et.s_IsMileageCode = 'Y' and et.s_IsPrivateMileage = 'N') ty on el.line_id = ty.line_id where eh.status_id = '34' group by u.u_logon_name, ty.TaxYear
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code