Add weeks in a query?
Posted on
16th Feb 2014 07:03 pm by
admin
I have a SQL that summarizes the quantity per week. The weeks that has no value does not exist in the table. How can I add these missing weeks with a 0 value in the SQL. Need this to use Avg and stddev functions.
SELECT t.material, t.description,
Sum(t.sales_quantity ) qty, to_char(t.Posting_Date,'IYYYIW') year_week
FROM tblBilling t
Where t.material = 'label900'
And t.Posting_date >= to_date('2008-10-20','yyyy-mm-dd')
And t.Posting_date <= to_date('2009-10-20','yyyy-mm-dd')
Group By t.material, t.description, to_char(t.Posting_Date,'IYYYIW')
This return:
material descriotion qty year_week
label900 test 20000 200850
label900 test 10000 200910
label900 test 5000 200912
label900 test 6000 200914
label900 test 9000 200920
I want it to complement the missing weeks with 0. Like this:
material descriotion qty year_week
label900 test 0 200843
label900 test 0 200844
label900 test 0 200845
label900 test 0 200846
label900 test 0 200847
label900 test 0 200848
label900 test 0 200849
label900 test 20000 200850
label900 test 0 200851
--and so on
Your Answer:
Login to answer
66 46
Other forums
Unable to customise toolbar in FCK
Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t
Storing Values taken from a DB...
Using this code it will generate a short list from my database
<?php
mysql_connect
mysql_affected_rows() usage
Possibly a MySQL issue, but the function that is not behaving in the anticipated way is a PHP functi
MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an erro
Post, not working, please help
The error is:
Method Not Allowed
The requested method POST is not allowed for the URL /student
'210010106140040100' == '210010106140040101'
Debugging this simple line of a PHP script
Code: if($a == $b){ }
I've found that with val
how to remove in php string display
My code is
$message="We're looking at developing our website.";
$body= "
Pipe email to PHP - get mail adress from MySQL - send?
Hi all,
this is the challenge:
1) Our faculty at the college where I'm employed includ
How to kill asynchronous postback / current postback?
Hi,here is my problem:I have a web site with many pages of which some may take time to process resul