Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. [HttpGet("[action]")]
  2. [Authorize]
  3. public ListResult ProblemsYTD(int year = "")
  4. {
  5. var sql = "SELECT DatePart(yyyy, CLL.Call_Log_Date) as [ProblemsYear], CLL.Service as [Service], Sum((DATEDIFF(dd, CLL.Call_Log_Date, GetDate()))) as [DaysOpen] " +
  6. "FROM VMWareSM_Test.dbo.RV_CALL as CLL " +
  7. "Where CLL.IPK_Stream_Ref = '19' And DatePart(yyyy, CLL.Call_Log_Date)";
  8.  
  9. int myInt;
  10. if (!int.TryParse(year, out myInt))
  11. {
  12. year = "%" + year + "%";
  13. sql += " = @year";
  14. }
  15.  
  16. sql += " Group by CLL.Service, DatePart(yyyy, CLL.Call_Log_Date) "+
  17. "Order by CLL.Service DESC; ";
  18.  
  19. SqlParameter[] sqlParams =
  20. {
  21. new SqlParameter
  22. {
  23. ParameterName = "@year",
  24. Value = year,
  25. DbType = DbType.Int32,
  26. Direction = ParameterDirection.Input
  27. }
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement