How do I find the total number of used days in a month?

前端 未结 2 798
北荒
北荒 2020-12-10 09:16

I am arriving at the total number of days a service has been used in a month. (Start_Date and End_Date are - both inclusive)

Sample Data 1:

User  Sta         


        
2条回答
  •  爱一瞬间的悲伤
    2020-12-10 09:44

    As @Pravin Satav addressed, your requirement it's not very clear, something like this is what I understood from your explanation:

    SELECT sum(CASE WHEN end_date=start_date THEN 1 ELSE (end_date-start_date)+1 END) as total_days
    FROM my_table
    WHERE ;
    

提交回复
热议问题