date - Selecting the current week of data and reseting from week to week -


i want select data current week. so... if current date monday select monday if current date tuesday select monday , tuesday's data if current date wednesday select monday, tuesday , wednesday ...and on. want reset on sunday , believe it's kind of "where" clause don't know what. can see below i'm counting number of pieces oven , want accumulate week goes on , reset on sunday.

select count(*) piecesintooven ovenfeederfloat where...??

thanks help.

if you're looking in sql server, see below. converts current date numeric (0-6) value, finds 0th date week , uses set lower bound of clause.

select sum(numberofpieces) test dateofwork <= getdate() , dateofwork >= (dateadd(day, datepart(weekday,getdate()) * -1, getdate()) + 1) 

note '0' value impacted datefirst. https://stackoverflow.com/a/1113891/4824030

i'm not how in oracle. below should work, it's being finicky in sqlfiddle.

select sum(numberofpieces) test dateofwork <= current_timestamp , dateofwork >= (((to_char(level+trunc(current_timestamp,'d'),'day') * -1) + current_timestamp) + 1) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -