Question: What's the probability for a quarter to have 14 Tuesdays? Solution: This is a crude, brute-force solution: just check all quarters in history since AD 1 to, say, the end of 2019. Create a table to hold all days since 0001-01-01, i.e. 365.2422*2019=737424.002 days: create table alldates (x date); begin for i in 0..737424 loop insert into alldates values (to_date('00010101','yyyymmdd')+i); end loop; end; / SQL> alter session set nls_date_format='yyyy-mm-dd'; Session altered. SQL> select min(x), max(x), count(*) from alldates; MIN(X) MAX(X) COUNT(*) ---------- ---------- ---------- 0001-01-01 2019-12-30 737425 Maybe because the average number of days I use is a little smaller than it should be, total days fall short by 1. Let's add it. insert into alldates values ('2019-12-31'); To speed up the next step which is to populate the day of week count table, do this: create index alldates_tocharx on alldates (to_char(x,'D')); create index alldates_tocharx2 on alldates (to_char(x,'yyyymmdd')); exec dbms_stats.gather_table_stats(user, 'ALLDATES') Create the second table to store count of a specific day of week for each quarter: create table cntdow_by_qt (qt varchar2(6), cnt_dow number); Populate it, one quarter at a time. Since we only care about Tuesdays, just populate Tuesday in spite of the name of the table. The four loops below, each for one range of years, may be merged into one to look more elegant but the code may be less readable. Variable i is the year number; i||'-1' is just a string that means the 1st quarter of that year and so on. Oracle function to_char(,'D') gives day of week (3 means Tues). begin for i in 1..9 loop insert into cntdow_by_qt select i||'-1', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '000'||i||'0101' and '000'||i||'0331'; insert into cntdow_by_qt select i||'-2', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '000'||i||'0401' and '000'||i||'0630'; insert into cntdow_by_qt select i||'-3', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '000'||i||'0701' and '000'||i||'0930'; insert into cntdow_by_qt select i||'-4', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '000'||i||'1001' and '000'||i||'1231'; end loop; for i in 10..99 loop insert into cntdow_by_qt select i||'-1', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '00'||i||'0101' and '00'||i||'0331'; insert into cntdow_by_qt select i||'-2', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '00'||i||'0401' and '00'||i||'0630'; insert into cntdow_by_qt select i||'-3', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '00'||i||'0701' and '00'||i||'0930'; insert into cntdow_by_qt select i||'-4', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '00'||i||'1001' and '00'||i||'1231'; end loop; for i in 100..999 loop insert into cntdow_by_qt select i||'-1', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '0'||i||'0101' and '0'||i||'0331'; insert into cntdow_by_qt select i||'-2', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '0'||i||'0401' and '0'||i||'0630'; insert into cntdow_by_qt select i||'-3', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '0'||i||'0701' and '0'||i||'0930'; insert into cntdow_by_qt select i||'-4', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between '0'||i||'1001' and '0'||i||'1231'; end loop; for i in 1000..2019 loop insert into cntdow_by_qt select i||'-1', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between i||'0101' and i||'0331'; insert into cntdow_by_qt select i||'-2', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between i||'0401' and i||'0630'; insert into cntdow_by_qt select i||'-3', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between i||'0701' and i||'0930'; insert into cntdow_by_qt select i||'-4', count(*) from alldates where to_char(x,'D')='3' and to_char(x,'yyyymmdd') between i||'1001' and i||'1231'; end loop; end; / Now the result: SQL> select cnt_dow, count(*) from cntdow_by_qt where qt like '%-1' group by cnt_dow order by 1; CNT_DOW COUNT(*) ---------- ---------- 12 216 <-- 216 1st quarters from AD 1 to the end of 2019 have 12 Tuesdays 13 1803 <-- 1803 1st quarters have 13 Tuesdays SQL> select cnt_dow, count(*) from cntdow_by_qt where qt like '%-2' group by cnt_dow order by 1; CNT_DOW COUNT(*) ---------- ---------- 13 2019 <-- all 2019 2nd quarters have 13 Tuesdays SQL> select cnt_dow, count(*) from cntdow_by_qt where qt like '%-3' group by cnt_dow order by 1; CNT_DOW COUNT(*) ---------- ---------- 13 1731 14 288 <-- 288 3rd quarters have 14 Tuesdays SQL> select cnt_dow, count(*) from cntdow_by_qt where qt like '%-4' group by cnt_dow order by 1; CNT_DOW COUNT(*) ---------- ---------- 12 1 <-- 1 4th quarter only has 12 Tuesdays 13 1730 14 288 <-- 288 4th quarters have 14 Tuesdays SQL> select count(*) from cntdow_by_qt where cnt_dow=14; COUNT(*) ---------- 576 <-- 576 quarters in history have 14 Tuesdays SQL> select count(*) from cntdow_by_qt; COUNT(*) ---------- 8076 <-- this many quarters in total SQL> select 576/8076 from dual; 576/8076 ---------- .071322437 So, the answer is 7.13%, i.e. a quarter has 7.13% probability to have 14 Tuesdays in the past 2019 years. Curiously, in history, there was one 4th quarter with only 12 Tuesdays, and that quarter is: SQL> select qt from cntdow_by_qt where qt like '%-4' and cnt_dow=12; QT ------ 1582-4 What's special about the 4th quarter of AD 1582? October of that year is missing 10/05 through 10/14 per a papal bull (see https://en.wikipedia.org/wiki/1582), and our alldates table shows that too: SQL> alter session set nls_date_format='yyyy-mm-dd'; Session altered. SQL> select * from alldates where x between '1582-10-01' and '1582-10-31' order by 1; X ---------- 1582-10-01 1582-10-02 1582-10-03 1582-10-04 1582-10-15 <-- Oracle database faithfully skips 5th through 14th of that month; 9th would have been a Tuesday 1582-10-16 1582-10-17 ... although on Linux, the `cal' command apparently doesn't honor the papal decree: $ cal 10 1582 October 1582 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31