Get BulkRevenue as well as non-bulk revenue

I'm trying to get the SUM of revenue where BulkOrder = 0 and 1, can anyone help?
http://pastebin.com/q07KHJh5
Thanks,
Michael

Thanks for your help, Visakh16, but i'm getting a weird result - this is my current query based on your answer:
SELECT     
COUNT(dbo.[Order].OrderID) AS Orders,
CASE WHEN BulkOrder = 0 THEN (SUM(dbo.OrderLine.SubTotal) + SUM(dbo.OrderLine.Shipping) - SUM(dbo.OrderLine.Discount)) ELSE 0 END AS Revenue,
CASE WHEN BulkOrder = 1 THEN (SUM(dbo.OrderLine.SubTotal) + SUM(dbo.OrderLine.Shipping) - SUM(dbo.OrderLine.Discount)) ELSE 0 END AS BulkRevenue,
DATEADD(dd, 0, DATEDIFF(dd, 0, dbo.[Order].PaymentDate)) AS RevenueDate, (SUM(dbo.OrderLine.SubTotal) + SUM(dbo.OrderLine.Shipping)) / COUNT(dbo.[Order].OrderID) AS RevenuePerOrder,
SUM(dbo.OrderLine.Qty) AS Qty
FROM         dbo.[Order]     
INNER JOIN
dbo.OrderLine ON dbo.[Order].OrderID = dbo.OrderLine.OrderID
WHERE             
(dbo.[Order].OrderStatusID IN (2))
AND (dbo.[Order].PaymentDate >= CONVERT(DATETIME, '02/03/2014', 103))         
AND (dbo.[Order].PaymentDate <= CONVERT(DATETIME, '08/03/2014 23:59:59', 103))         
AND (dbo.[Order].WebsiteID = 1)
GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, dbo.[Order].PaymentDate)), dbo.[Order].WebsiteID, dbo.[Order].BulkOrder
and I get this data:
Orders Revenue BulkRevenue RevenueDate RevenuePerOrder Qty
35    0    0    2014-03-02 00:00:00.000    19.9934285714286    36
29    0    0    2014-03-03 00:00:00.000    25.0720689655172    32
43    0    0    2014-03-04 00:00:00.000    20.8841860465116    44
46    0    0    2014-03-05 00:00:00.000    20.5723913043478    46
45    0    0    2014-03-06 00:00:00.000    20.4562222222222    45
37    0    0    2014-03-07 00:00:00.000    22.6051351351351    38
27    0    0    2014-03-08 00:00:00.000    21.9933333333333    27
Thanks,
Michael

Similar Messages

  • Problem in finding the Duplicate as well as Non-Duplicate count

    Hi,
    I have a scenario where I have a table TABLEA which has 3 values
    10 ABC
    10 ABC
    20 DEF
    I want to pick up the duplicate count as wel as non duplicate count:
    I have used the following query:
    SELECT COUNT(*) FROM TABLEA A WHERE A.ROWID > ANY (
    SELECT B.ROWID FROM TABLEA B WHERE
    A.CODE=B.CODE)
    But I am finding problem in getting the non-duplicate count .
    Any help will be needful for me
    Edited by: user598986 on Sep 23, 2009 11:32 PM

    user598986 wrote:
    Hi,
    I have a scenario where I have a table TABLEA which has 3 values
    10 ABC
    10 ABC
    20 DEF
    I want to pick up the duplicate count as wel as non duplicate count:
    I have used the following query:
    SELECT COUNT(*) FROM TABLEA A WHERE A.ROWID > ANY (
    SELECT B.ROWID FROM TABLEA B WHERE
    A.CODE=B.CODE)
    But I am finding problem in getting the non-duplicate count .
    Any help will be needful for me
    Edited by: user598986 on Sep 23, 2009 11:32 PMHi,
    perhaps this query makes your job:
    HR: XE > select * from test_;
    NAME           SALARY HIRE_DATE START_DAT END_DATE
                          15-SEP-09 15-SEP-09
                          15-SEP-09 01-DEC-09
    john                  27-AUG-09 16-SEP-09 16-SEP-10
                          28-FEB-09 20-SEP-09
    Dave                2 17-JUN-08 16-SEP-09 02-JUL-11
                     1000 21-AUG-82 08-MAY-10
    6 rows selected.
    HR: XE > select count(hire_date), hire_date from test_
      2  group by hire_date;
    COUNT(HIRE_DATE) HIRE_DATE
                   1 27-AUG-09
                   1 21-AUG-82
                   2 15-SEP-09
                   1 28-FEB-09
                   1 17-JUN-08
    HR: XE > select count(id), id from
      2  (
      3  select hire_date, 'simple' id from test_
      4  minus
      5  select test_.hire_date, 'simple' id
      6  from test_
      7  where test_.hire_date In (Select hire_date FROM test_  GROUP BY hire_date HAVING Count(*)>1 )
      8  union all
      9  select test_.hire_date, 'double' id
    10  from test_
    11  where test_.hire_date In (Select hire_date FROM test_  GROUP BY hire_date HAVING Count(*)>1 )
    12  )
    13  group by id;
    COUNT(ID) ID
             2 double
             4 simple
    HR: XE > Regards,
    Ion

  • How to get selected row from a non-bind ADF table

    Hi,
    I have an ADF table that is based on a collectionModel built programmatically. The collectionModel is this:
    model = new SortableModel(new ArrayList<ArrayList>());
    Hence, it is not a binding table. My question is how to get the selectedRows from a non-bind table.
    I am used to building binding ADF table and I know we can get it from voiterator.getCurrentRow, since the selectionListener is set to the binding....collectionModel.makeCurrent
    <af:table value="#{bindings.ItasLookupTypesVO1.collectionModel}"
    selectedRowKeys="#{bindings.ItasLookupTypesVO1.collectionModel.selectedRow}"
    selectionListener="#{bindings.ItasLookupTypesVO1.collectionModel.makeCurrent}"
    </af:table>
    I am thinking maybe I need to write my own selectionListener, but need more advice/ideas of what's the codes in the customer selection Listener to get it from my SortableModel.
    Please help.
    Thanks
    -Mina

    I'm not sure if this works in your case, but check out the selection listener I write in this blog http://wp.me/pcBZk-eu
    You should use the selection event and check the added set. This should give you access to the selected row.
    Timo

  • I can no longer edit song and album information in iTunes. I right click on the album, the window opens with "get info", "rating", etc., but none of it operates. What did I change to make it stop working?

    I can no longer edit album or song information in iTunes. I right-click on the album (or song), and the window opens with "get info", "rating", etc., but none of it operates. It won't get or save album art, anything. What have I changed to make it all stop working?

    You are describing an iTunes problem, not an iPod touch problem. Try posing in the iTunes forum.

  • Getting a request in a non English character

    Hi ,
    In an attempt to solve a problem of getting a request in a non English character , i use the code , taken from O'Reilly's "Java Servlet programing" First edition:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class MyServlet extends HttpServlet {
         public void doGet(HttpServletRequest req, HttpServletResponse res)
                                                                               throws ServletException, IOException {
              try {
                                                      //set encoding of request and responce
         req.setCharacterEncoding("Cp1255"); //for hebrew windows
         res.setCharacterEncoding("Cp1255");
         res.setContentType("Text/html; Cp1255");
         String value = req.getParameter("param");
                                                      // Now convert it from an array of bytes to an array of characters.
         // Here we bother to read only the first line.
                                                      BufferedReader reader = new BufferedReader(
         new InputStreamReader(new StringBufferInputStream(value), "Cp1255"));
                                                      String valueInUnicode = reader.readLine();
              }catch (Exception e) {
              e.printStackTrace();
    this works fine , the only problem is that StringBufferInputStream is deprecated .
    is there any other alternative for that ?
    Thanks in advance
    Yair

    Hi Again ..
    To get to the root of things , here is a servlet test and an http client test which demonstrates using the above patch and not using it :
    The servlet :
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.io.StringBufferInputStream;
    public class Hebrew2test extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              request.setCharacterEncoding("Cp1255");
              response.setCharacterEncoding("Cp1255");
              response.setContentType("Text/html; Cp1255");
              PrintWriter out = response.getWriter();
              String name = request.getParameter("name");
              //print without any patch
              out.println(name);
              //a try with patch 1 DEPRECATED
              out.println("patch 1:");
              BufferedReader reader =
              new BufferedReader(new InputStreamReader(new StringBufferInputStream(name), "cp1255"));
              String patch_name = reader.readLine();
              out.println(patch_name);
              //a try with patch 2 which doesn't work          
              out.println("patch 2:");
              String valueInUnicode = new String(name.getBytes("Cp1255"), "UTF8");
              out.println(valueInUnicode);
    and now for a test client :
    import java.io.*;
    import java.net.*;
    public class HttpClient_cp1255 {
    private static void printUsage() {
    System.out.println("usage: java HttpClient host port");
    public static void main(String[] args) {
    if (args.length < 2) {
    printUsage();
    return;
    // Host is the first parameter, port is the second
    String host = args[0];
    int port;
    try {
    port = Integer.parseInt(args[1]);
    catch (NumberFormatException e) {
    printUsage();
    return;
    try {
    // Open a socket to the server
    Socket s = new Socket(host, port);
    // Start a thread to send reuest to the server
    new Request_(s).start();
    // Now print everything we receive from the socket
    BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream(),"cp1255"));
    String line;
    File f = new File("in.txt");
    FileWriter out = new FileWriter(f);
    while ((line = in.readLine()) != null) {
    System.out.println(line);
    out.write(line);
    out.close();
         catch (Exception e) {
    e.printStackTrace();
    class Request_ extends Thread {
    Socket s;
    public Request_( Socket s) {
    this.s = s;
    setPriority(MIN_PRIORITY); // socket reads should have a higher priority
    // Wish I could use a select() !
    setDaemon(true); // let the app die even when this thread is running
    public void run() {
    try {
                        OutputStreamWriter server = new OutputStreamWriter(s.getOutputStream(),"cp1255");
                        //String query= "GET /userprofiles/hebrew2test?name=yair"; //yair in Englisg ..
                        String query= "GET /userprofiles/hebrew2test?name=\u05d9\u05d0\u05d9\u05e8"; //yair in hebrew - in unicode
                   System.out.println("Connected... your HTTP request is sent");
                        System.out.println("------------------------------------------");
                        server.write(query);
                        server.write("\r\n"); // HTTP lines end with \r\n
                        server.flush();
                        System.out.println(server.getEncoding());
         server =      new OutputStreamWriter(new FileOutputStream("out.txt"),"cp1255");
                        server.write(query);
                        server.flush();
    catch (Exception e) {
    e.printStackTrace();

  • Non Bulk stock ageing report

    please let me know if any standard functionality available to have NON BULK ageing report.
    Thanks

    pls check MC46 and also from MC41 to MC50
    Thx
    Raju

  • I had a "pdf export" plan and upgraded it to "pdf pack" plan and it was charged the full price of the new plan in my credit card. How to get the refund of the non used part of the old plan?

    I had a "pdf export" plan and upgraded it to "pdf pack" plan and it was charged the full price of the new plan in my credit card. How to get the refund of the non used part of the old plan?

    Hi edilsoncf,
    I've seen your question on several forums, and responded there. Did you get your subscription sorted out?
    See: How do I get a refund if I have multiple Acrobat service subscriptions?
    Best,
    Sara

  • Which CZ-Schema tables get affected when we create Non BOM items in OCD?

    Hi,
    Please LIST ALL the CZ tables which gets affected when we create Non BOM structure.
    Or Else Atleast suggest a means where I can get which tables are getting affected(i.e, In which CZ tables rows are being inserted).
    Thanks.
    Edited by: 1008308 on May 28, 2013 2:03 AM

    I cannot speak for Murali, but from my experience...this information is not available in particular manual or documentation. These table names are known over the course of working with the product over a period of time, seeing SQL statements inside working code, working on bugs alongside Oracle Support and Development, etc. However, there is some information available in the following locations to help you out:
    * CZ Implementation Guide - Section D - CZ Subschemas (http://docs.oracle.com/cd/E18727_01/doc.121/e14322/T440679CHDJBBFB.htm). This part of the manual lists the key tables used for various activities (product structure, publishing, UI, etc.)
    * ETRM (http://etrm.oracle.com) also has some useful information. Not every table is described, but many of them are. As an example, here is what you might find as a description of the CZ_PS_NODES table:
    +"The CZ_PS_NODES table contains the entire structure of a product model. Data can be imported from Oracle Bill of Materials. Each project has a root (product) node. When the project structure is imported, project structure nodes mirror the imported BOM structure. Nodes of type REFERENCE are used to include a separate project ("model") into another psnode project tree."+
    Thanks,
    Jason

  • How to I get the card information to none so I can download my free apps it won't let me it keeps asking for card information

    How to I get the card information to none so I can download my free apps it won't let me it keeps asking for card information

    Is it a new account ? If it is then unless the instructions on this page are followed when creating an account : http://support.apple.com/kb/HT2534
    then credit card details will need to be entered before the account can be used to download any item from the store - you should be able to remove your card details after entering them

  • SCHEDULES: NON PROJECT REVENUE REPORT

    HI GURUS,
    can you please tell me where to find out the standard reports and Datasources used and Tables related to  <b>NON PROJECT REVENUE</b>.
    points will be given.
    Thanks
    regards

    Hello
    what is the source of non revenue. Is it booked to a GL account ?
    Non billable recievables is a special GL account.
    Check OUVR for setting.
    Even deferred revenue is a special GL account.
    Once you know where the amounts are booked. Execute a normal standard report from GL info systems.
    Reg

  • How do I get rid of and prevent non-content mails dated 1970-01-01?

    How do I get rid of and prevent non-content mails dated 1970-01-01? They come by the hundreds!!

    CSS:
    #navigation {margin-top: -3px;}
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • I'm getting a error that says NONE when I'm trying to reset up Adobe Photoshop Element. How do I fix it?

    I'm getting a error that says NONE when I'm trying to reset up Adobe Photoshop Element. How do I fix it? I already have the program but updated my computer from Vista to windows 7, and it didn't transfer over. What do I do?

    Sorry, but I'm not clear when you get the message NONE.
    Which version of Photoshop Elements do you have?
    Have you installed Photoshop Elements on your Windows 7 system?
    What are you doing when you get the message NONE?
    Brian

  • I have two personal e-mail accounts and a general account that I have synced to my Mail app, but I keep getting emails sent to the non-personal e-mail because they're on the same server. How can I change that?

    I have two personal e-mail accounts and a general account that I have synced to my Mail app, but I keep getting emails sent to the non-personal e-mail because they're on the same server. How can I change that?

    The only ways I know of for email to get sent to an account are:
    1. It was addressed to that account. Someone used that email address to send you the email.
    2. It was forwarded to that account by the account to which it had been addressed. I am not aware of Mail having this feature but it is often a feature provided by your ISP that you can turn on by logging into your account via the Internet and setting it up.  I assume you have not done this, though.
    With several email addresses in the same Mail client, you have to be careful which one you are sending from. If you send from the wrong address, any replies will come back to that same address. I make this mistake all too often.

  • NON PROJECT REVENUE

    HI GURUS,
    can you please tell me where to find out the standard reports and Datasources used and Tables related to<b> NON PROJECT REVENUE.</b>
    points will be given.
    Thanks
    regards

    Hello
    what is the source of non revenue. Is it booked to a GL account ?
    Non billable recievables is a special GL account.
    Check OUVR for setting.
    Even deferred revenue is a special GL account.
    Once you know where the amounts are booked. Execute a normal standard report from GL info systems.
    Reg

  • Mail: Forwarding: Original Sender Gets Email as Well?

    I haven't been using Mail very long -- I used to use Eudora for decades and it was my definitely favorite email app. I hated Outlook et. al and when I bought my MacBook Pro and it was running 10.5.8, well, I just could not get Eudora to work. So I reluctantly had to switch to Mail, which I hated then, and hate even more now.
    A couple of times, I was horrified to see that when I forwarded email from someone to my wife, and perhaps added a comment with the quoted text of the email, the original sender whose email i was forwarding got the email -- with my comment -- as well!
    Since I don't know what's going on, I don't know how to explain it, but here's an example. Someone emailed me about taking some lessons (I teach Japanese). I replied and said I couldn't take her right now, which wasn't true -- she was already asking for a group discount for two people and I know the type and I just didn't want to bother with it, so I said I was too busy.
    Then, I forwarded the email she had sent me, with the request for the discount, to my wife. I specifically chose the "Forward" button, my wife's address appeared in the address box, and I included some snide comment about why the woman was asking for a discount on a discount, as I'm already way cheaper than most turors.
    Still with me?
    Then, later on I changed my mind and replied to the woman and told her I could fit her in, but she'd have to pay the full price. I BCCd my wife in on this email (Bcc means "Blind CC" -- meaning, as I understand it, that the main person recieving the email only sees their address in the header, and possibly "and other recipients," but not anyone else's email address or anything like that.
    So, we go back and forth over various things, and occasionally I forward the woman's email to my wife, again, with comments, that I OBVIOUSLY don't want this woman to see.
    Okay, no problems there -- before I click "Send" I make sure my wife's address, and ONLY her address, is in the address field, as I'm just forwarding an email.
    Yet today, when I went to check what time this person is coming, I see all the emails that we've ever exchanged including the very first one, all one after another -- her emails, my replies etc. But then, in the middle of all these, I suddenly see the email I forwarded to my wife with the snide comment in it! How the **** did it get in there, and is it possible that email was also sent to this woman as well, so she read my comment?
    Other odd things have happened when I've forwarded things to my wife -- a reply, perhaps, from someone we both know but with my previous emails, NOT MEANT to be read by my wife, somehow in the chain!
    Now I'm ultra paranoid. Has this woman received those emails I sent to my wife (I thought) and read my snide comments? Why on erth would Mail include, in this bck and forth with this woman -- maybe ten emails in all, suddenly a forwarded email to my wife? It should not be in the chain at all, since it was NOT sent to the woman, merely forwarded to my wife.
    Is Mail sending emails to people with their email addresses being visible in the address fields without my knowledge? Has this woman read my snide comments (and my wife's replies to them!) and even if not, why are those back-and-forths with my wife doing in the same chain as the emails to this woman? They technically should have no connection to the woman, since they were nit addressed to her, merely forwarded.
    And are people seeing who I'm Blind CCing? Mail certainly is an effed-up app -- it's very badly putr together and just serves to remind me that Apple has really put some horrific software into their systems over the years, and seemingly with every new iteratioon and every new OS, the apps just get worse and less intuitive, not the opposite, with NO WAY to downgrade. If I had my way, this MacBook would be running Tiger. with iMovie from 2004 (same for all the iLife apps -- they've degenerated into Microsoft-like unusable messes).
    But I'm seriously worried about this Mail issue -- the last thing I want is for people to be receiving emails that I'm not aware are being sent.
    And I REALLY wish Eudora functioned on this machine -- I don't know why it doesn't but it keeps giving me error messages. But that's a separate problem.
    Anyone else experienced anything like this?

    Thanks, guys . . .
    I kind of knew that Mail couldn't possibly be sending emails to people without my being aware of it but I just wanted to double check.
    As far as the other email programs go, for some insane reason all the ones I try (Thunderbird, for one) have problems connecting with my SMTP (outgoing) server. In one case, there's no way to change my account setting from IMAP to POP . . . the way these programs are set up, just configuring your settings requires a B.S. in network technology . . . every time these things happen, I end up on the phone with the local ISP for two hours and most of them have no idea what a Mac is  . . .
    I think in this case I wll just stick wth the Devil I Know. Every email program has its drawbacks and Mail is clunky and unintuitive but thank God, it integrates with SpamSieve, the only junk mail killer that really, really works (I just learned how WELL it works when I tried Thunderbird and it downloaded all the mail I'm REALLY getting s opposed to the mail that I end up seeing -- for every legit email that SpamSieve lets through, there are at least 75 that it doesn't. I don't know about anyone else, but I'm inundated with at LEAST 400 junk emails A DAY for my two accounts and without SpamSieve I'd be in the First Circle of ****, but I digress).
    It's been a year now with Mail and although I despise it at least now I think I'm getting used to it, and your reassurances about people getting unwanted mail definitely removed my last doubts.
    I'll stick with Mail, since the others don't look exactly like champs either, and just pray Apple doesn't "Upsdate" anything for a good long while.
    Cheers, mates
    Nick

Maybe you are looking for