oracle - SQL query for all the days of a month -



oracle - SQL query for all the days of a month -

i have next table rental(book_date, copy_id, member_id, title_id, act_ret_date, exp_ret_date). book_date shows day book booked. need write query every day of month(so 1-30 or 1-29 or 1-31 depending on month) shows me number of books booked. know how show number of books rented in days in table

select count(book_date), to_char(book_date,'dd') rental grouping to_char(book_date,'dd');

my questions are:

how show rest of days(if let's reason in database have no books rented on 20th or 19th or multiple days) , set number 0 there? how show number of days of current month so(28,29,30,31 these 4 possible depending on month or year)... lost . must done using sql query no pl/sql or other stuff.

the next query give days in current month, in case can replace sysdate date column , bring together query know how many given month

select dt from( select trunc (last_day(sysdate) - rownum) dt dual connect rownum < 32 ) dt >= trunc(sysdate,'mm')

sql oracle

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -