SQLQuery1.sql 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /****** Script for SelectTopNRows command from SSMS ******/
  2. /*
  3. SELECT [id]
  4. ,[from]
  5. ,[checkcontent]
  6. ,[clientqq]
  7. ,[contact]
  8. ,[clerk]
  9. ,[useqq]
  10. ,[date]
  11. ,[time]
  12. ,[question]
  13. ,[solution]
  14. ,[result]
  15. ,[autoid]
  16. FROM [Internal].[dbo].[clientservice] where clerk = '黄飞' and [date] > '2015-01-01' and [date] < '2016-01-01' */
  17. -- select * from [clientservice] where clerk = '黄飞' and [date] > '2015-01-01' and [date] < '2016-01-01'
  18. --1
  19. select
  20. count(*) as '远程总数',
  21. count(case result when '满意' then 'ok'end) ,
  22. count(case result when '非常满意' then 'ok'end) ,
  23. count(case result when '不满意' then 'ok'end) ,
  24. count(case result when '一般' then 'ok'end) ,
  25. count(case result when 'ok' then 'ok'end) --,clerk
  26. from [clientservice]
  27. where [date] > '2015-01-01' and [date] < '2016-01-01'
  28. group by clerk order by clerk
  29. --2
  30. select
  31. count(*) as '远程总数',
  32. count(case result when '满意' then 'ok'end) ,
  33. count(case result when '非常满意' then 'ok'end) ,
  34. count(case result when '不满意' then 'ok'end) ,
  35. count(case result when '一般' then 'ok'end) ,
  36. count(case result when 'ok' then 'ok'end)
  37. from [clientservice]
  38. where clerk = '黄飞'
  39. and [date] > '2015-01-01' and [date] < '2016-01-01'
  40. select count(result) from [clientservice] where clerk = '黄飞' and [date] > '2015-01-01' and [date] < '2016-01-01' and result = '不满意'