Announcement

Collapse
No announcement yet.

SQL Code sanity check request

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SQL Code sanity check request

    Hi guys,

    I've just knocked up a query to get the daily sales figures out of the database and wonder if someone can have a look to see if I've missed anything obvious. It all seems to work OK, but you never know. Sellerdeck no longer release information about the schema, so you have to just suck it and see.

    Anyway, here's my code:


    Code:
    SELECT Date_Ordered
          ,sum(ord_total_cost+ord_ship_tot_cost+ord_disc_cost) as total_daily_sales
    FROM (SELECT Order.[Order Number]
                ,Format(Order.[Date Ordered],"Short Date") AS Date_Ordered
                ,Sum(OrderDetail.[TotalCost])/100 AS ord_total_cost
                , Order.[Shipping Total Cost]/100 AS ord_ship_tot_cost
                , Order.[Discount Cost]/100 AS ord_disc_cost
          FROM [Order] INNER JOIN OrderDetail 
          ON Order.[Order Sequence Number] = OrderDetail.OrderSequenceNumber
          where OrderDetail.Status <> "C"
          GROUP BY Order.[Order Number]
                 , Format(Order.[Date Ordered],"Short Date")
                 , Order.[Shipping Total Cost]
                 , Order.[Discount Cost]) AS TOTALS
    GROUP BY  TOTALS.DATE_ORDERED
    The Patchwork Rabbit

    #2
    Also, does anyone know what the values for

    OrderDetail.nLineType

    denote?

    Thanks!
    The Patchwork Rabbit

    Comment


      #3
      Originally posted by PatchworkRabbit View Post
      Also, does anyone know what the values for

      OrderDetail.nLineType

      denote?

      Thanks!
      0=Product
      1=Component
      2=Product Adjustment
      3=Order Adjustment
      4=Offline Adjustment

      Malcolm

      SellerDeck Accredited Partner,
      SellerDeck 2016 Extensions, and
      Custom Packages

      Comment


        #4
        Originally posted by PatchworkRabbit View Post
        Hi guys,

        I've just knocked up a query to get the daily sales figures out of the database and wonder if someone can have a look to see if I've missed anything obvious. It all seems to work OK, but you never know. Sellerdeck no longer release information about the schema, so you have to just suck it and see.
        Hi

        You might want to take account of those orders where there is a partial cancellation of an order line, does depend on what is being sold of course.

        OrderDetail.QuantityOrdered
        OrderDetail.QuantityCancelled

        Malcolm

        SellerDeck Accredited Partner,
        SellerDeck 2016 Extensions, and
        Custom Packages

        Comment


          #5
          Ah, thank you :-)
          The Patchwork Rabbit

          Comment

          Working...
          X