How to include the nulls??

Hi, I have the following query stored:
SELECT     dbo.OrderDetails_Retail.ProductID, dbo.OrderDetails_Retail.ProductName, SUM(dbo.OrderDetails_Retail.Quantity) AS ProdQtyPerWeek, DATEPART(wk,
                      dbo.Orders_Retail.OrderDate) AS SalesWeek, YEAR(dbo.Orders_Retail.OrderDate) AS SalesYear
FROM         dbo.OrderDetails_Retail INNER JOIN
                      dbo.Orders_Retail ON dbo.OrderDetails_Retail.OrderID = dbo.Orders_Retail.OrderID
WHERE     (dbo.Orders_Retail.account = @Account) AND (dbo.Orders_Retail.OrderStatus <> 'Deleted') AND (dbo.Orders_Retail.PayStatus <> 'Pending') AND
                      (dbo.Orders_Retail.OrderStatus <> 'Refunded') AND (DATEDIFF(d, dbo.Orders_Retail.OrderDate, @StartDate) <= 0) AND (DATEDIFF(d,
                      dbo.Orders_Retail.OrderDate, @EndDate) >= 0)
GROUP BY YEAR(dbo.Orders_Retail.OrderDate), DATEPART(wk, dbo.Orders_Retail.OrderDate), dbo.OrderDetails_Retail.ProductID,
                      dbo.OrderDetails_Retail.ProductName
ORDER BY dbo.OrderDetails_Retail.ProductID, dbo.OrderDetails_Retail.ProductName, YEAR(dbo.Orders_Retail.OrderDate), DATEPART(wk,
                      dbo.Orders_Retail.OrderDate)
Basically, it will return a load of results grouped by product for how much qty of that product was sold per week during a date range...
As my client wants to select multiple products at once to compare rather than do it in my application (I'm building something in ASP), I thought I might be able to do it on the database side.
The problem with the above is that.. lets say I select a date range that has weeks 1-4 in it.
Product 1 only sold qty's for weeks 1-2, product 2 sold for only week 3 and product  4 sold in all four weeks.
I'd get
Prod | Qty | Week
1          23     1
1          12     2
2          10     3
3          22      1
3          15       2
3          12       3
3          4         4
Although this looks fine - what I actually need is:
1          23     1
1           12      2
1          0        3
1         0         3
2          0         1
2          0         2
2          10     3
2          0         4
3          22      1
3          15       2
3          12       3
3          4         4
Does that make sense?
Any ideas on how to do this?

ok I'm getting somewhere with this now.. however I have another problem.. here's the current query
SELECT     dbo.Products.ProductID, dbo.Products.ProductName, dbo.Products.ProductBrand, SUM(dbo.OrderDetails_Retail.Quantity) AS Qty, DATEPART(wk,
                      dbo.Orders_Retail.OrderDate) AS SalesWeek, YEAR(dbo.Orders_Retail.OrderDate) AS SalesYear
FROM         dbo.Orders_Retail INNER JOIN
                      dbo.OrderDetails_Retail ON dbo.Orders_Retail.OrderID = dbo.OrderDetails_Retail.OrderID INNER JOIN
                      dbo.Calendar ON CONVERT(datetime, CONVERT(Nvarchar, dbo.Orders_Retail.OrderDate, 102), 102) = CONVERT(datetime, CONVERT(Nvarchar,
                      dbo.Calendar.dt, 102), 102) RIGHT OUTER JOIN
                      dbo.Products ON dbo.OrderDetails_Retail.ProductID = dbo.Products.ProductID
WHERE     (dbo.Orders_Retail.account = @Account) AND (dbo.Orders_Retail.OrderStatus <> '
                       Deleted ') AND
                      (dbo.Orders_Retail.PayStatus <> ' Pending ') AND (dbo.Orders_Retail.OrderStatus <> ' Refunded ') AND (DATEDIFF(d, dbo.Orders_Retail.OrderDate,
                      @StartDate) <= 0) AND (DATEDIFF(d, dbo.Orders_Retail.OrderDate, @EndDate) >= 0)
GROUP BY YEAR(dbo.Orders_Retail.OrderDate), DATEPART(wk, dbo.Orders_Retail.OrderDate), dbo.Products.ProductID, dbo.Products.ProductName,
                      dbo.Products.ProductBrand
ORDER BY YEAR(dbo.Orders_Retail.OrderDate), DATEPART(wk, dbo.Orders_Retail.OrderDate), dbo.Products.ProductBrand, dbo.Products.ProductName
What this does is first get the products tbl, join that the orders_detail tbl, joins that the orders tbl which is finally joined to the calendar tbl.
What I'm finding is although it's working as intended, it's still not returning the product that haven't been bought..
I've narrowed this down to the following:
It I just to a Outer join on the products tbl to the order details tbl with no WHERE queries.. this returned what I want,, however as soon as I add the WHERE clause, it loses all the products and only shows the ones that have been purchased.
I would have thoughy my Outer join on the products tbl would get round this problem?

Similar Messages

  • How to include the page dynamically in JSF

    Hi all
    Below is static include
    <jsp:include page="../inc/sideMenu.inc"/>
    How to include the file dynamically
    Thanks

    Hi,
    Though I have not tried it I think making use of a variable to hold the page name to be included should work. Could you try this and see if it works?
    Cheers
    Giri :-)

  • How to include the pages dynamically in JSF

    Hi all
    Below is static include
    <jsp:include page="../inc/sideMenu.inc"/>How to include the file dynamically
    Thanks
    Sudhakar

    Hi,
    Though I have not tried it I think making use of a variable to hold the page name to be included should work. Could you try this and see if it works?
    Cheers
    Giri :-)

  • How to include the insert picture option in the PDF form?

    Hi, Can some one please help How to include the insert picture option in the PDF form? I am using acrobat XI pro and trying to use an evaluation form which requires to insert product pictures.

    Here's a link to a previous topic where this was discussed: http://forums.adobe.com/message/6050458

  • How to Include the URL of a page in Notification Email ?

    Hi ALL,
    I need your help to implement the below requirement.
    I have implemented Email notification in our application.so when ever the user creates any form/modify the form ,mail will be triggered to them.Now the users want to include the link in the email.
    When they click the link in email ,it should be navigated to the newly created form page in Apex.
    How to include the link of the page in the Email process?
    Thanks,
    Ramya.

    Hi Tuceef,
    Thanks for the response.
    I have created another hidden item P8_URL1 IN page 8 and
    I have created an on submit process in page processing section.
    the pl/sql code is
    Begin
    htp.p('<script type = "text/javascript">');
    function setLocation(href)
               // set the location path specified in the textbox.
               htp.p('location.href = document.getElementById(href).value;');
              htp.p('P8_URL1:= location.href');
    htp.p('</script>');
    end;But the code fetching the plain URL only,it's navigating to the empty form page when i click on the URL.
    Please correct the code if am wrong anywhere!
    Thanks & Regards,
    Ramya.

  • How to Include the Infocubes in a Multiprovider..!!

    Hello Experts,
    Question is related to multiproviders. I have some 20 to 30 of the infocubes in Dev System.
    I have 2 multiproviders in the same system. I come to know..some of the infocubes missed out in multiproviders.
    I tried to add those missed infocubes into multiprovider (MPRO --> Context Menu --> Change ) Change Structure.
    But i found some of the infocubes are not available in the MPRO Structure Itself. For your info those all missed infocubes all are avaialable in the Dev system into some other info areas.
    Now Question is how to include the infocubes of which of them are not available in MPRO Structure itself. I want to add the infocubes in the Multiprovider itself.
    Please reply me the answer for the above scenario.
    Thanks and Regards,
    SN.

    Hi Parvin,
    Thanks for your reply. But i already tried as you mentioned.
    Here my issue is..even for giving the tickmark also..the infocube needs to be opened in the MPRO structure.
    My problem is Infocube itself is not opening in MPRO Structure.
    How to include the infocube in the MPRO Structure itself.
    Those cubes are avaialable in the Dev system where as those are not available in MPRO.
    Thanks,
    SN

  • How to include the simbol % in a flash chart

    hello everyone
    Do you know how to include the simbol % in a flash chart?
    I am using a 3D flash chart. This simbol obviously would be after that number of percentage.
    Do I must modify the chart XML adding some after that {VALUE} ?
    Any help would be very appreciated
    Thank you in advance
    Best Regards

    Erik:
    You can specify the '%' in the 'Postfix' field in the 'Display Settings' on the 'Chart Attributes' page.
    Varad

  • How to include the hebrew languare in the Oracle Data?

    Hi All,
    I'm using this code in nls_lang value in the registry to include Arabic and English languages in the data:
    AMERICAN_AMERICA.AR8MSWIN1256
    but how to include the hebrew language to be used in the data also Plz?
    Note: I'm using Oracle DB 10g R2

    Your database character set (SELECT value FROM nls_database_parameters WHERE parameter='NLS_CHARACTERSET') must be AL32UTF8 to support both Arabic and Hebrew. The client must be Unicode-enabled to enter both languages simultaneously.
    -- Sergiusz

  • How to include the Pipe symbol ("|") in the column heading.

    Hi ,
    Can somebody advice how to include the Pipe symbol ("|") in the column heading.
    Regards,
    Yagne

    Are you looking for this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>set colsep '|'
    satyaki>
    satyaki>select * from emp;
         EMPNO|ENAME     |JOB      |       MGR|HIREDATE |       SAL|      COMM|    DEPTNO|JOB1     |DOB
    ----------|----------|---------|----------|---------|----------|----------|----------|---------|----
          7499|ALLEN     |SALESMAN |      7698|20-FEB-81|     211.2|       300|        30|SALESMAN |
          7521|WARD      |SALESMAN |      7698|22-FEB-81|      1650|       500|        30|SALESMAN |
          7654|MARTIN    |SALESMAN |      7698|28-SEP-81|      1650|      1400|        30|SALESMAN |
          7788|SCOTT     |ANALYST  |      7566|19-APR-87|      4356|          |        20|ANALYST  |
          7839|KING      |PRESIDENT|          |17-NOV-81|      6600|          |        10|PRESIDENT|
          7844|TURNER    |SALESMAN |      7698|08-SEP-81|      1980|         0|        30|SALESMAN |
          7876|ADAMS     |CLERK    |      7788|23-MAY-87|     145.2|          |        20|CLERK    |
          7900|JAMES     |CLERK    |      7698|03-DEC-81|      1254|          |        30|CLERK    |
          7902|FORD      |ANALYST  |      7566|03-DEC-81|    4791.6|          |        20|ANALYST  |
          7934|MILLER    |CLERK    |      7782|23-JAN-82|      1716|          |        10|CLERK    |
          7566|Smith     |Manager  |      7839|23-JAN-82|      1680|         0|        10|Manager  |23-JAN-89
         EMPNO|ENAME     |JOB      |       MGR|HIREDATE |       SAL|      COMM|    DEPTNO|JOB1     |DOB
    ----------|----------|---------|----------|---------|----------|----------|----------|---------|----
          7698|Glen      |Manager  |      7839|23-JAN-82|      1680|         0|        10|Manager  |23-JAN-89
          1111|Selen     |SALESMAN |      7499|20-FEB-81|      1920|         0|        20|SALESMAN |23-JAN-89
          1111|Selen     |SALESMAN |      7499|19-OCT-08|      3000|         0|        10|         |
          7499|ALLEN     |SALESMAN |      7499|19-OCT-08|      3000|         0|        30|         |
             1|boock     |         |          |         |          |          |          |         |
    16 rows selected.
    Elapsed: 00:00:01.03
    satyaki>Regards.
    Satyaki De.

  • How to include the first row of detail in every xquery transformed xml?

    I am dealing with a XML file,where i need to publish to different BS.
    First node will be a common node node which contains vital info,second node goes to one BS and third goes to another BS.
    *<header></header>*
    *<details></details> (they are unbounded, but the first detail tag which comes in the input file is a mandatory tag in such a way that it needs to be included in every transformed message)*
    *<trailer></trailer>*
    We need to apply x query transformation on it in such a way:
    *</header></header>*
    *<1st detail></1st detail>*
    *<detail></detail> (2nd row of detail in input file)* -------------------------> Goes to BS1
    *<trailer></trailer>..*
    *<header></header>*
    *<1st detail></1st detail>*
    *<detail></detail> (3rd row of detail in input file)* ----------------------------->Goes to BS2
    *<trailer></trailer>*..
    And so on.
    Now, the problem is how to include the first row( *1st detail* ) of detail in every xquery transformed xml?

    are you looping of this input with a for each?
    /yourdata/details[1] should return always the first detail element.
    or before the for each do an assing of this first detail element to "generic_details_var"
    and use this var in every looping iteration (in an assign or as input for xquery)

  • How to include the promotion and sales deal in the value contract ?

    Question : Can a value contract contain other special pricing agreement ?
    If yes, how to include the promotion and sales deal in the value contract ?
    Thanks for your input.
    Oscar

    Hi Oscar,
    I have not worked on this aspect as such but once you create a value contract I think you as well create a promotion and sales deal for the customer with whom you have value contract with in the validity period of the contract and system should pick up data accordingly as the customer is same (Contract) and is within the validity period.
    Pl give feed back.
    regards
    Srini

  • How to include the file name as an XML field

    Hi,
    I'm using a file adapter for process a flat file and convert it into an XML. Does anybody knows how to include the file name into an XML field.
    Ex.
    I process the file named <b>XXIMN21022007.txt</b> and I need an XML like:
    <MT_FILE>
    <field1></field1>
    <field2></field2>
    <field3></field3>
    <filename><b>XXIMN21022007.txt</b></filename>
    </MT_FILE>
    Regards
    Gonzalo

    Just go for dynamic configuration.
    Check the sender file adapter to write the filename in the header (as explained in Michal's blog) and then read that header in some mapping.
    U can use that even in simple message mappings.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm
    Your code for the filename tag would be something like:
    <i>DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        “http://sap.com/xi/XI/System/File”,
        “FileName”);
    return conf.get(key);</i>
    Regards,
    Henrique.

  • Can any one tell me how to include the company logo and some poictures into the Teststand report

    1. Can any one tell me how to include the company logo and some pictures into the Teststand report?
    2. How to include the waveforms into the report?

    http://zone.ni.com/devzone/cda/epd/p/id/3619
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • How to include the missing PF status in screen

    Hello All,
    How to include the missing Pf-status in screen?
    Regards,
    Lisa.

    check if the pf-status you use currently has all needed functions
    if yes, probably you call it with an EXCLUDING statement and you have to remove some functions from the internal table of exclusions
    if no, you have either to enhance this pf-status with additional functions either to copy it and enhance the copy, then call the copy in your program

  • How to avoid the null values from xml publisher.

    I am creating a report which have the claim numbers with the values CLA001,CLA111,null, null . when i preview my report it is showing some spaces for null values also. How can i avoid the spaces from the report.
    I am giving for loop for the claim numbers in the template.
    <?for-each:ROW?> <?sort:CLAIMNUMBER;'ascending';data-type='text'?>
    <?CLAIMNUMBER?>
    <?end for-each?>
    Please help me out to solve this problem.
    Thanks,
    vasanth.

    Hi Sheshu,
    According to your description, you are experiencing the null values and infinity values when browser the calculated measure, right?
    Based on my research, the issue is caused by that dividing a non-zero or non-null value by zero or null. In this cases, we need to check for division by zero to avoid this situation. Here is the sample query for you reference.
    IIF(
    Measures.[Measure B]=0,null,
    Measures.[Measure A] / Measures.[Measure B]
    If you have any questions, please feel free to ask.
    Regards,
    Charlie Liao
    TechNet Community Support

Maybe you are looking for

  • Can i still get a replacement for my iphone at a price if it's already been opened by a friend?

    hi, my iphone 5 came in contact with liqiud and it ont come on. a friend of mine opened it up to check the LCI and try to fix it. can i still get it replaced for a fee at an apple store? i tried but apparently they wont replace it if there has been t

  • JTable display question - Center alignment

    Is there any way to control the display alignment (center, for eg) of table cells in a column without writing a custom's cell renderer? Thanks for any hint!

  • Monitor on top?

    A friend of mine with limited desk space just bought a mini. We are wondering if it's okay to put the monitor (22" LCD) on top of the computer. The aluminum frame certainly seems strong enough and the DSL modem is close by (I've heard of some concern

  • Multiple SPNs per instance?

    Multiple Instance, Multiple Statically Assigned ports 'per' instance.  eg; Instance1 - ports 15000, 15001, 15002 Instance2 - ports 16000, 16001, 16002 Port 15000 - DatabaseA Port 15002 - DatabaseB Port 15002 - DatabaseC Port 16000 - DatabaseD Port 16

  • Problem with iPhone Headset after plugging and unplugging from PC

    Hello First I would like to introduce myself, My name is Lukasz and I can very happy customer company Apple. but... I have one problem, which is really annoying , I hope that someone will be able to help me...here we A 3 months ago I bought a Apple H