Number of fridays between two dates

前端 未结 7 1893
我寻月下人不归
我寻月下人不归 2020-12-06 06:58

How do I find the number of fridays between two dates(including both the dates) using a select statement in oracle sql?

相关标签:
7条回答
  • 2020-12-06 07:48

    See:

    Why should I consider using an auxiliary calendar table?

    The article's code is specifically for SQL Server but the techniques are portable to most SQL platforms.

    With a Calendar table in place your query could be as simple as

    SELECT COUNT(*) AS friday_tally
      FROM YourTable AS T1
           INNER JOIN Calendar AS C1
              ON C1.dt BETWEEN T1.start_date AND T1.end_date
     WHERE C1.day_name = 'Friday'; -- could be a numeric code
    
    0 讨论(0)
提交回复
热议问题