Peak Vehicle Acquisition Cost In 100$ Increments Over Six Months
Peak Vehicle Acquisition Cost in 100$ Increments Over Six Months
{
  "__inputs": [
    {
      "name": "DS_POWERLINK",
      "label": "Powerlink",
      "description": "",
      "type": "datasource",
      "pluginId": "mssql",
      "pluginName": "Microsoft SQL Server"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.4.4"
    },
    {
      "type": "panel",
      "id": "grafana-piechart-panel",
      "name": "Pie Chart",
      "version": "1.3.9"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "mssql",
      "name": "Microsoft SQL Server",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": false,
  "gnetId": 11425,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Others",
        "threshold": 0
      },
      "datasource": "${DS_POWERLINK}",
      "decimals": 2,
      "description": "",
      "fontSize": "80%",
      "format": "none",
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 10,
      "interval": "",
      "legend": {
        "header": "",
        "percentage": true,
        "percentageDecimals": 2,
        "show": true,
        "sort": "total",
        "sortDesc": true,
        "values": true
      },
      "legendType": "Right side",
      "links": [],
      "maxDataPoints": 3,
      "nullPointMode": "connected",
      "options": {},
      "pieType": "pie",
      "strokeWidth": 1,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "rawSql": "\r\n\r\nSELECT \r\n\r\n--MAX(DateCreated) AS DateCreated,\r\n$__timeGroup(DateCreated, '1d') AS time,  \r\nMAX(Acquisition_Cost_Range) AS Acquisition_Cost_Range, \r\n      --COUNT(STOCKTICKETNUMBER) AS VEHICLE_COUNT\r\n\r\n       --MAX(MODELYEAR) AS MODELYEAR,\r\n       --MAX(MODEL) AS MODEL,\r\n       --MAX(AGEINDAYS) AS AGEINDAYS,\r\n       --SUM(GROSSREVENUE) AS GROSSREVENUE,\r\n       --SUM(TOTALACQUISITIONCOST) AS TOTALACQUISITIONCOST,\r\n       ROUND(CONVERT(MONEY, SUM(NETREVENUE)), 2) AS NETREVENUE\r\nFROM\r\n(\r\n    SELECT DISTINCT TOP 100 PERCENT StockTicketNumber, \r\n                                    DateCreated,\r\n                                    ModelYear, \r\n                                    Model, \r\n                                    AgeInDays, \r\n                                    GrossRevenue, \r\n                                    TotalAcquisitionCost, \r\n                                    NetRevenue, \r\n                                    (CASE\r\n                                         WHEN TotalAcquisItionCost * 1.00 <= -5001.00\r\n                                         THEN '-5000.00 +'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-5000.99 AND-4901.00\r\n                                         THEN '-5000.99 TO -4901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4900.99 AND-4801.00\r\n                                         THEN '-4900.99 TO -4801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4800.99 AND-4701.00\r\n                                         THEN '-4800.99 TO -4701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4700.99 AND-4601.00\r\n                                         THEN '-4700.99 TO -4601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4600.99 AND-4501.00\r\n                                         THEN '-4600.99 TO -4501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4500.99 AND-4401.00\r\n                                         THEN '-4500.99 TO -4401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4400.99 AND-4301.00\r\n                                         THEN '-4400.99 TO -4301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4300.99 AND-4201.00\r\n                                         THEN '-4300.99 TO -4201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4200.99 AND-4101.00\r\n                                         THEN '-4200.99 TO -4101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4100.99 AND-4001.00\r\n                                         THEN '-4100.99 TO -4001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4000.99 AND-3901.00\r\n                                         THEN '-4000.99 TO -3901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3900.99 AND-3801.00\r\n                                         THEN '-3900.99 TO -3801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3800.99 AND-3701.00\r\n                                         THEN '-3800.99 TO -3701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3700.99 AND-3601.00\r\n                                         THEN '-3700.99 TO -3601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3600.99 AND-3501.00\r\n                                         THEN '-3600.99 TO -3501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3500.99 AND-3401.00\r\n                                         THEN '-3500.99 TO -3401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3400.99 AND-3301.00\r\n                                         THEN '-3400.99 TO -3301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3300.99 AND-3201.00\r\n                                         THEN '-3300.99 TO -3201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3200.99 AND-3101.00\r\n                                         THEN '-3200.99 TO -3101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3100.99 AND-3001.00\r\n                                         THEN '-3100.99 TO -3001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3000.99 AND-2901.00\r\n                                         THEN '-3000.99 TO -2901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2900.99 AND-2801.00\r\n                                         THEN '-2900.99 TO -2801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2800.99 AND-2701.00\r\n                                         THEN '-2800.99 TO -2701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2700.99 AND-2601.00\r\n                                         THEN '-2700.99 TO -2601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2600.99 AND-2501.00\r\n                                         THEN '-2600.99 TO -2501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2500.99 AND-2401.00\r\n                                         THEN '-2500.99 TO -2401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2400.99 AND-2301.00\r\n                                         THEN '-2400.99 TO -2301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2300.99 AND-2201.00\r\n                                         THEN '-2300.99 TO -2201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2200.99 AND-2101.00\r\n                                         THEN '-2200.99 TO -2101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2100.99 AND-2001.00\r\n                                         THEN '-2100.99 TO -2001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2000.99 AND-1901.00\r\n                                         THEN '-2000.99 TO -1901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1900.99 AND-1801.00\r\n                                         THEN '-1900.99 TO -1801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1800.99 AND-1701.00\r\n                                         THEN '-1800.99 TO -1701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1700.99 AND-1601.00\r\n                                         THEN '-1700.99 TO -1601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1600.99 AND-1501.00\r\n                                         THEN '-1600.99 TO -1501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1500.99 AND-1401.00\r\n                                         THEN '-1500.99 TO -1401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1400.99 AND-1301.00\r\n                                         THEN '-1400.99 TO -1301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1300.99 AND-1201.00\r\n                                         THEN '-1300.99 TO -1201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1200.99 AND-1101.00\r\n                                         THEN '-1200.99 TO -1101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1100.99 AND-1001.00\r\n                                         THEN '-1100.99 TO -1001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1000.99 AND-901.00\r\n                                         THEN '-1000.99 TO -901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-900.99 AND-801.00\r\n                                         THEN '-900.99 TO -801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-800.99 AND-701.00\r\n                                         THEN '-800.99 TO -701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-700.99 AND-601.00\r\n                                         THEN '-700.99 TO -601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-600.99 AND-501.00\r\n                                         THEN '-600.99 TO -501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-500.99 AND-401.00\r\n                                         THEN '-500.99 TO -401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-400.99 AND-301.00\r\n                                         THEN '-400.99 TO -301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-300.99 AND-201.00\r\n                                         THEN '-300.99 TO -201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-200.99 AND-101.00\r\n                                         THEN '-200.99 TO -101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-199.99 AND-1.00\r\n                                         THEN '-100.99 TO -1.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-0.99 AND-0.01\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 0.00 AND 0.99\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1.00 AND 100.99\r\n                                         THEN '1.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 101.00 AND 200.99\r\n                                         THEN '101.00 TO 200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 201.00 AND 300.99\r\n                                         THEN '201.00 TO 300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 301.00 AND 400.99\r\n                                         THEN '301.00 TO 400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 401.00 AND 500.99\r\n                                         THEN '401.00 TO 500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 501.00 AND 600.99\r\n                                         THEN '501.00 TO 600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 601.00 AND 700.99\r\n                                         THEN '601.00 TO 700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 701.00 AND 800.99\r\n                                         THEN '701.00 TO 800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 801.00 AND 900.99\r\n                                         THEN '801.00 TO 900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 901.00 AND 1000.99\r\n                                         THEN '901.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1001.00 AND 1100.99\r\n                                         THEN '1000.00 TO 1100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1101.00 AND 1200.99\r\n                                         THEN '1101.00 TO 1200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1201.00 AND 1300.99\r\n                                         THEN '1201.00 TO 1300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1301.00 AND 1400.99\r\n                                         THEN '1301.00 TO 1400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1401.00 AND 1500.99\r\n                                         THEN '1401.00 TO 1500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1501.00 AND 1600.99\r\n                                         THEN '1501.00 TO 1600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1601.00 AND 1700.99\r\n                                         THEN '1601.00 TO 1700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1701.00 AND 1800.99\r\n                                         THEN '1701.00 TO 1800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1801.00 AND 1900.99\r\n                                         THEN '1801.00 TO 1900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1901.00 AND 2000.99\r\n                                         THEN '1901.00 TO 2000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2001.00 AND 2100.99\r\n                                         THEN '2001.00 TO 2100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2101.00 AND 2200.99\r\n                                         THEN '2101.00 TO 2200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2201.00 AND 2300.99\r\n                                         THEN '2201.00 TO 2300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2301.00 AND 2400.99\r\n                                         THEN '2301.00 TO 2400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2401.00 AND 2500.99\r\n                                         THEN '2401.00 TO 2500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2501.00 AND 2600.99\r\n                                         THEN '2501.00 TO 2600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2601.00 AND 2700.99\r\n                                         THEN '2601.00 TO 2700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2701.00 AND 2800.99\r\n                                         THEN '2701.00 TO 2800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2801.00 AND 2900.99\r\n                                         THEN '2801.00 TO 2900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2901.00 AND 3000.99\r\n                                         THEN '2901.00 TO 3000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3001.00 AND 3100.99\r\n                                         THEN '3000.00 TO 3100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3101.00 AND 3200.99\r\n                                         THEN '3101.00 TO 3200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3201.00 AND 3300.99\r\n                                         THEN '3201.00 TO 3300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3301.00 AND 3400.99\r\n                                         THEN '3301.00 TO 3400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3401.00 AND 3500.99\r\n                                         THEN '3401.00 TO 3500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3501.00 AND 3600.99\r\n                                         THEN '3501.00 TO 3600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3601.00 AND 3700.99\r\n                                         THEN '3601.00 TO 3700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3701.00 AND 3800.99\r\n                                         THEN '3701.00 TO 3800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3801.00 AND 3900.99\r\n                                         THEN '3801.00 TO 3900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3901.00 AND 4000.99\r\n                                         THEN '3901.00 TO 4000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4001.00 AND 4100.99\r\n                                         THEN '4000.00 TO 4100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4101.00 AND 4200.99\r\n                                         THEN '4101.00 TO 4200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4201.00 AND 4300.99\r\n                                         THEN '4201.00 TO 4300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4301.00 AND 4400.99\r\n                                         THEN '4301.00 TO 4400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4401.00 AND 4500.99\r\n                                         THEN '4401.00 TO 4500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4501.00 AND 4600.99\r\n                                         THEN '4501.00 TO 4600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4601.00 AND 4700.99\r\n                                         THEN '4601.00 TO 4700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4701.00 AND 4800.99\r\n                                         THEN '4701.00 TO 4800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4801.00 AND 4900.99\r\n                                         THEN '4801.00 TO 4900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4901.00 AND 5000.99\r\n                                         THEN '4901.00 TO 5000.99'\r\n                                         ELSE(CASE\r\n                                                  WHEN TotalAcquisItionCost >= 5000.99\r\n                                                  THEN '5000 +'\r\n                                              END)\r\n                                     END) AS Acquisition_Cost_Range\r\n    FROM\r\n    (\r\n        SELECT DISTINCT TOP (100) PERCENT Veh.StockTicketNumber, \r\n                                          INV.DateCreated, \r\n                                          Veh.ModelYear, \r\n                                          Veh.ModelName AS Model, \r\n                                          ISNULL(DATEDIFF(day, Veh.DatePhysicallyAcquired, GETDATE()), 0) AS AgeInDays, \r\n                                          ISNULL(VR.TotalRev, 0) AS GrossRevenue, \r\n                                          ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0) AS TotalAcquisitionCost, \r\n                                          ISNULL(VR.TotalRev, 0) - (ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0)) AS NetRevenue\r\n        FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n             INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n             INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n             INNER JOIN VEHICLE AS Veh WITH(NOLOCK) ON Veh.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                       AND Veh.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                       AND Veh.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n             INNER JOIN STORE AS St ON St.StoreNumber = Veh.StoreNumber\r\n                                       AND St.YardNumber = Veh.YardNumber\r\n             LEFT OUTER JOIN VEHICLE_COST_PAYMENT AS VCP WITH(NOLOCK) ON Veh.StockTicketNumber = VCP.StockTicketNumber\r\n                                                                         AND Veh.StoreNumber = VCP.StoreNumber\r\n                                                                         AND Veh.YardNumber = VCP.YardNumber\r\n             LEFT OUTER JOIN EMPLOYEE AS emp WITH(NOLOCK) ON Veh.Buyer = emp.EmployeeID\r\n             LEFT OUTER JOIN\r\n        (\r\n            SELECT YardNumber, \r\n                   StoreNumber, \r\n                   StockTicketNumber, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS TotalRev, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) <= 89)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M1, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 90 AND 179)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M4, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 180 AND 269)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M7, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(day, V.DatePhysicallyAcquired, INV.DateCreated) >= 270)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M10\r\n            FROM VEHICLE AS veh WITH(NOLOCK)\r\n        ) AS VR ON Veh.YardNumber = VR.YardNumber\r\n                   AND Veh.StoreNumber = VR.StoreNumber\r\n                   AND Veh.StockTicketNumber = VR.StockTicketNumber\r\n        WHERE(DATEDIFF(DD, INV.DateCreated, GETDATE()) BETWEEN 0 AND 180)\r\n             AND (Veh.StoreNumber = 5)\r\n        ORDER BY TotalAcquisitionCost DESC\r\n    ) AS SUBSET--) AS FINALSET\r\n    WHERE Model > '' AND TotalAcquisitionCost >0\r\n    ORDER BY TotalAcquisitionCost ASC\r\n) AS FINALSET\r\nGROUP BY $__timeGroup(DateCreated, '1d') , \r\n\r\nAcquisition_Cost_Range\r\nORDER BY  \r\n\r\n--DateCreated ASC\r\n$__timeGroup(DateCreated, '1d') ASC",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Vehicle  Net Revenue Percentages In $100 Acquisition Cost Increments Over Six Months",
      "type": "grafana-piechart-panel",
      "valueName": "total"
    },
    {
      "cacheTimeout": null,
      "columns": [],
      "datasource": "${DS_POWERLINK}",
      "description": "",
      "fontSize": "100%",
      "gridPos": {
        "h": 14,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "id": 11,
      "interval": "",
      "links": [],
      "options": {},
      "pageSize": null,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "NETREVENUE",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "MM/DD/YYYYY",
          "decimals": 2,
          "pattern": "DateCreated",
          "thresholds": [],
          "type": "date",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "POSITIVE_NET_REVENUE",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "NEGATIVE_NET_REVENUE",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "Acquisition_Cost_Range",
          "preserveFormat": true,
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "PERCENTAGE_NOT_PROFITABLE",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        },
        {
          "alias": "",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "PERCENTAGE_PROFITABLE",
          "thresholds": [],
          "type": "number",
          "unit": "none"
        }
      ],
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "\r\nSELECT \r\n\r\n--MAX(DateCreated) AS DateCreated,\r\n--$__timeGroup(DateCreated, '1d') AS time,  \r\nMAX(Acquisition_Cost_Range) AS Acquisition_Cost_Range, \r\n      --COUNT(STOCKTICKETNUMBER) AS VEHICLE_COUNT\r\n\r\n       --MAX(MODELYEAR) AS MODELYEAR,\r\n       --MAX(MODEL) AS MODEL,\r\n       --MAX(AGEINDAYS) AS AGEINDAYS,\r\n       --SUM(GROSSREVENUE) AS GROSSREVENUE,\r\n       --SUM(TOTALACQUISITIONCOST) AS TOTALACQUISITIONCOST,\r\n       --SUM(NETREVENUE) AS NETREVENUE,\r\n\t   SUM((CASE WHEN NETREVENUE >0 THEN NETREVENUE ELSE 0.00 END)) AS POSITIVE_NET_REVENUE,\r\n\t   SUM((CASE WHEN NETREVENUE <0 THEN NETREVENUE ELSE 0.00 END)) AS NEGATIVE_NET_REVENUE,\r\n\t   (SUM((CASE WHEN NETREVENUE >0 THEN NETREVENUE ELSE 0.00 END))/SUM((CASE WHEN NETREVENUE <0 THEN (NETREVENUE *-1.00) ELSE NETREVENUE END)))*100.00 AS PERCENTAGE_PROFITABLE,\r\n\t  (SUM((CASE WHEN NETREVENUE <0 THEN (NETREVENUE*-1.00) ELSE 0 END))/SUM((CASE WHEN NETREVENUE <0 THEN (NETREVENUE *-1.00) ELSE NETREVENUE END)))*100.00 AS PERCENTAGE_NOT_PROFITABLE\r\n\t  \r\nFROM\r\n(\r\n    SELECT DISTINCT TOP 100 PERCENT StockTicketNumber, \r\n                                    DateCreated,\r\n                                    ModelYear, \r\n                                    Model, \r\n                                    AgeInDays, \r\n                                    GrossRevenue, \r\n                                    TotalAcquisitionCost, \r\n                                    NetRevenue, \r\n                                    (CASE\r\n                                         WHEN TotalAcquisItionCost * 1.00 <= -5001.00\r\n                                         THEN '-5000.00 +'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-5000.99 AND-4901.00\r\n                                         THEN '-5000.99 TO -4901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4900.99 AND-4801.00\r\n                                         THEN '-4900.99 TO -4801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4800.99 AND-4701.00\r\n                                         THEN '-4800.99 TO -4701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4700.99 AND-4601.00\r\n                                         THEN '-4700.99 TO -4601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4600.99 AND-4501.00\r\n                                         THEN '-4600.99 TO -4501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4500.99 AND-4401.00\r\n                                         THEN '-4500.99 TO -4401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4400.99 AND-4301.00\r\n                                         THEN '-4400.99 TO -4301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4300.99 AND-4201.00\r\n                                         THEN '-4300.99 TO -4201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4200.99 AND-4101.00\r\n                                         THEN '-4200.99 TO -4101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4100.99 AND-4001.00\r\n                                         THEN '-4100.99 TO -4001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4000.99 AND-3901.00\r\n                                         THEN '-4000.99 TO -3901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3900.99 AND-3801.00\r\n                                         THEN '-3900.99 TO -3801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3800.99 AND-3701.00\r\n                                         THEN '-3800.99 TO -3701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3700.99 AND-3601.00\r\n                                         THEN '-3700.99 TO -3601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3600.99 AND-3501.00\r\n                                         THEN '-3600.99 TO -3501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3500.99 AND-3401.00\r\n                                         THEN '-3500.99 TO -3401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3400.99 AND-3301.00\r\n                                         THEN '-3400.99 TO -3301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3300.99 AND-3201.00\r\n                                         THEN '-3300.99 TO -3201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3200.99 AND-3101.00\r\n                                         THEN '-3200.99 TO -3101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3100.99 AND-3001.00\r\n                                         THEN '-3100.99 TO -3001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3000.99 AND-2901.00\r\n                                         THEN '-3000.99 TO -2901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2900.99 AND-2801.00\r\n                                         THEN '-2900.99 TO -2801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2800.99 AND-2701.00\r\n                                         THEN '-2800.99 TO -2701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2700.99 AND-2601.00\r\n                                         THEN '-2700.99 TO -2601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2600.99 AND-2501.00\r\n                                         THEN '-2600.99 TO -2501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2500.99 AND-2401.00\r\n                                         THEN '-2500.99 TO -2401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2400.99 AND-2301.00\r\n                                         THEN '-2400.99 TO -2301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2300.99 AND-2201.00\r\n                                         THEN '-2300.99 TO -2201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2200.99 AND-2101.00\r\n                                         THEN '-2200.99 TO -2101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2100.99 AND-2001.00\r\n                                         THEN '-2100.99 TO -2001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2000.99 AND-1901.00\r\n                                         THEN '-2000.99 TO -1901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1900.99 AND-1801.00\r\n                                         THEN '-1900.99 TO -1801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1800.99 AND-1701.00\r\n                                         THEN '-1800.99 TO -1701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1700.99 AND-1601.00\r\n                                         THEN '-1700.99 TO -1601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1600.99 AND-1501.00\r\n                                         THEN '-1600.99 TO -1501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1500.99 AND-1401.00\r\n                                         THEN '-1500.99 TO -1401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1400.99 AND-1301.00\r\n                                         THEN '-1400.99 TO -1301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1300.99 AND-1201.00\r\n                                         THEN '-1300.99 TO -1201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1200.99 AND-1101.00\r\n                                         THEN '-1200.99 TO -1101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1100.99 AND-1001.00\r\n                                         THEN '-1100.99 TO -1001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1000.99 AND-901.00\r\n                                         THEN '-1000.99 TO -901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-900.99 AND-801.00\r\n                                         THEN '-900.99 TO -801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-800.99 AND-701.00\r\n                                         THEN '-800.99 TO -701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-700.99 AND-601.00\r\n                                         THEN '-700.99 TO -601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-600.99 AND-501.00\r\n                                         THEN '-600.99 TO -501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-500.99 AND-401.00\r\n                                         THEN '-500.99 TO -401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-400.99 AND-301.00\r\n                                         THEN '-400.99 TO -301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-300.99 AND-201.00\r\n                                         THEN '-300.99 TO -201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-200.99 AND-101.00\r\n                                         THEN '-200.99 TO -101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-199.99 AND-1.00\r\n                                         THEN '-100.99 TO -1.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-0.99 AND-0.01\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 0.00 AND 0.99\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1.00 AND 100.99\r\n                                         THEN '1.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 101.00 AND 200.99\r\n                                         THEN '101.00 TO 200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 201.00 AND 300.99\r\n                                         THEN '201.00 TO 300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 301.00 AND 400.99\r\n                                         THEN '301.00 TO 400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 401.00 AND 500.99\r\n                                         THEN '401.00 TO 500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 501.00 AND 600.99\r\n                                         THEN '501.00 TO 600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 601.00 AND 700.99\r\n                                         THEN '601.00 TO 700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 701.00 AND 800.99\r\n                                         THEN '701.00 TO 800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 801.00 AND 900.99\r\n                                         THEN '801.00 TO 900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 901.00 AND 1000.99\r\n                                         THEN '901.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1001.00 AND 1100.99\r\n                                         THEN '1000.00 TO 1100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1101.00 AND 1200.99\r\n                                         THEN '1101.00 TO 1200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1201.00 AND 1300.99\r\n                                         THEN '1201.00 TO 1300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1301.00 AND 1400.99\r\n                                         THEN '1301.00 TO 1400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1401.00 AND 1500.99\r\n                                         THEN '1401.00 TO 1500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1501.00 AND 1600.99\r\n                                         THEN '1501.00 TO 1600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1601.00 AND 1700.99\r\n                                         THEN '1601.00 TO 1700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1701.00 AND 1800.99\r\n                                         THEN '1701.00 TO 1800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1801.00 AND 1900.99\r\n                                         THEN '1801.00 TO 1900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1901.00 AND 2000.99\r\n                                         THEN '1901.00 TO 2000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2001.00 AND 2100.99\r\n                                         THEN '2001.00 TO 2100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2101.00 AND 2200.99\r\n                                         THEN '2101.00 TO 2200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2201.00 AND 2300.99\r\n                                         THEN '2201.00 TO 2300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2301.00 AND 2400.99\r\n                                         THEN '2301.00 TO 2400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2401.00 AND 2500.99\r\n                                         THEN '2401.00 TO 2500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2501.00 AND 2600.99\r\n                                         THEN '2501.00 TO 2600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2601.00 AND 2700.99\r\n                                         THEN '2601.00 TO 2700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2701.00 AND 2800.99\r\n                                         THEN '2701.00 TO 2800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2801.00 AND 2900.99\r\n                                         THEN '2801.00 TO 2900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2901.00 AND 3000.99\r\n                                         THEN '2901.00 TO 3000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3001.00 AND 3100.99\r\n                                         THEN '3000.00 TO 3100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3101.00 AND 3200.99\r\n                                         THEN '3101.00 TO 3200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3201.00 AND 3300.99\r\n                                         THEN '3201.00 TO 3300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3301.00 AND 3400.99\r\n                                         THEN '3301.00 TO 3400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3401.00 AND 3500.99\r\n                                         THEN '3401.00 TO 3500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3501.00 AND 3600.99\r\n                                         THEN '3501.00 TO 3600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3601.00 AND 3700.99\r\n                                         THEN '3601.00 TO 3700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3701.00 AND 3800.99\r\n                                         THEN '3701.00 TO 3800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3801.00 AND 3900.99\r\n                                         THEN '3801.00 TO 3900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3901.00 AND 4000.99\r\n                                         THEN '3901.00 TO 4000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4001.00 AND 4100.99\r\n                                         THEN '4000.00 TO 4100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4101.00 AND 4200.99\r\n                                         THEN '4101.00 TO 4200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4201.00 AND 4300.99\r\n                                         THEN '4201.00 TO 4300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4301.00 AND 4400.99\r\n                                         THEN '4301.00 TO 4400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4401.00 AND 4500.99\r\n                                         THEN '4401.00 TO 4500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4501.00 AND 4600.99\r\n                                         THEN '4501.00 TO 4600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4601.00 AND 4700.99\r\n                                         THEN '4601.00 TO 4700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4701.00 AND 4800.99\r\n                                         THEN '4701.00 TO 4800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4801.00 AND 4900.99\r\n                                         THEN '4801.00 TO 4900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4901.00 AND 5000.99\r\n                                         THEN '4901.00 TO 5000.99'\r\n                                         ELSE(CASE\r\n                                                  WHEN TotalAcquisItionCost >= 5000.99\r\n                                                  THEN '5000 +'\r\n                                              END)\r\n                                     END) AS Acquisition_Cost_Range\r\n    FROM\r\n    (\r\n        SELECT DISTINCT TOP (100) PERCENT Veh.StockTicketNumber, \r\n                                          INV.DateCreated, \r\n                                          Veh.ModelYear, \r\n                                          Veh.ModelName AS Model, \r\n                                          ISNULL(DATEDIFF(day, Veh.DatePhysicallyAcquired, GETDATE()), 0) AS AgeInDays, \r\n                                          ISNULL(VR.TotalRev, 0) AS GrossRevenue, \r\n                                          ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0) AS TotalAcquisitionCost, \r\n                                          ISNULL(VR.TotalRev, 0) - (ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0)) AS NetRevenue\r\n        FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n             INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n             INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n             INNER JOIN VEHICLE AS Veh WITH(NOLOCK) ON Veh.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                       AND Veh.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                       AND Veh.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n             INNER JOIN STORE AS St ON St.StoreNumber = Veh.StoreNumber\r\n                                       AND St.YardNumber = Veh.YardNumber\r\n             LEFT OUTER JOIN VEHICLE_COST_PAYMENT AS VCP WITH(NOLOCK) ON Veh.StockTicketNumber = VCP.StockTicketNumber\r\n                                                                         AND Veh.StoreNumber = VCP.StoreNumber\r\n                                                                         AND Veh.YardNumber = VCP.YardNumber\r\n             LEFT OUTER JOIN EMPLOYEE AS emp WITH(NOLOCK) ON Veh.Buyer = emp.EmployeeID\r\n             LEFT OUTER JOIN\r\n        (\r\n            SELECT YardNumber, \r\n                   StoreNumber, \r\n                   StockTicketNumber, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS TotalRev, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) <= 89)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M1, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 90 AND 179)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M4, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 180 AND 269)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M7, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(day, V.DatePhysicallyAcquired, INV.DateCreated) >= 270)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M10\r\n            FROM VEHICLE AS veh WITH(NOLOCK)\r\n        ) AS VR ON Veh.YardNumber = VR.YardNumber\r\n                   AND Veh.StoreNumber = VR.StoreNumber\r\n                   AND Veh.StockTicketNumber = VR.StockTicketNumber\r\n        WHERE(DATEDIFF(DD, INV.DateCreated, GETDATE()) BETWEEN 0 AND 180)\r\n             AND (Veh.StoreNumber = 5)\r\n        ORDER BY TotalAcquisitionCost DESC\r\n    ) AS SUBSET--) AS FINALSET\r\n    WHERE Model > '' AND TotalAcquisitionCost >0\r\n    ORDER BY TotalAcquisitionCost ASC\r\n) AS FINALSET\r\nGROUP BY --$__timeGroup(DateCreated, '1d') , \r\n\r\nAcquisition_Cost_Range\r\nORDER BY  PERCENTAGE_PROFITABLE, PERCENTAGE_NOT_PROFITABLE DESC\r\n\r\n--DateCreated ASC\r\n--$__timeGroup(DateCreated, '1d') ASC",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Vehicle  Net Revenue Percentages In $100 Acquisition Cost Increments Over Six Months",
      "transform": "table",
      "type": "table"
    },
    {
      "aliasColors": {},
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Others",
        "threshold": 0
      },
      "datasource": "${DS_POWERLINK}",
      "decimals": 0,
      "description": "",
      "fontSize": "80%",
      "format": "none",
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 0,
        "y": 7
      },
      "id": 5,
      "interval": "",
      "legend": {
        "header": "",
        "percentage": true,
        "percentageDecimals": 0,
        "show": true,
        "sort": "total",
        "sortDesc": true,
        "values": true
      },
      "legendType": "Right side",
      "links": [],
      "maxDataPoints": 3,
      "nullPointMode": "connected",
      "options": {},
      "pieType": "pie",
      "strokeWidth": 1,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "rawSql": "\r\nSELECT \r\n\r\n--MAX(DateCreated) AS DateCreated,\r\n$__timeGroup(DateCreated, '1d') AS time,  \r\nMAX(Acquisition_Cost_Range) AS Acquisition_Cost_Range, \r\n      COUNT(STOCKTICKETNUMBER) AS VEHICLE_COUNT\r\n\r\n       --MAX(MODELYEAR) AS MODELYEAR,\r\n       --MAX(MODEL) AS MODEL,\r\n       --MAX(AGEINDAYS) AS AGEINDAYS,\r\n       --SUM(GROSSREVENUE) AS GROSSREVENUE,\r\n       --SUM(TOTALACQUISITIONCOST) AS TOTALACQUISITIONCOST,\r\n       --ROUND(CONVERT(MONEY, SUM(NETREVENUE)), 2) AS NETREVENUE\r\nFROM\r\n(\r\n    SELECT DISTINCT TOP 100 PERCENT StockTicketNumber, \r\n                                    DateCreated,\r\n                                    ModelYear, \r\n                                    Model, \r\n                                    AgeInDays, \r\n                                    GrossRevenue, \r\n                                    TotalAcquisitionCost, \r\n                                    NetRevenue, \r\n                                    (CASE\r\n                                         WHEN TotalAcquisItionCost * 1.00 <= -5001.00\r\n                                         THEN '-5000.00 +'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-5000.99 AND-4901.00\r\n                                         THEN '-5000.99 TO -4901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4900.99 AND-4801.00\r\n                                         THEN '-4900.99 TO -4801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4800.99 AND-4701.00\r\n                                         THEN '-4800.99 TO -4701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4700.99 AND-4601.00\r\n                                         THEN '-4700.99 TO -4601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4600.99 AND-4501.00\r\n                                         THEN '-4600.99 TO -4501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4500.99 AND-4401.00\r\n                                         THEN '-4500.99 TO -4401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4400.99 AND-4301.00\r\n                                         THEN '-4400.99 TO -4301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4300.99 AND-4201.00\r\n                                         THEN '-4300.99 TO -4201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4200.99 AND-4101.00\r\n                                         THEN '-4200.99 TO -4101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4100.99 AND-4001.00\r\n                                         THEN '-4100.99 TO -4001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4000.99 AND-3901.00\r\n                                         THEN '-4000.99 TO -3901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3900.99 AND-3801.00\r\n                                         THEN '-3900.99 TO -3801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3800.99 AND-3701.00\r\n                                         THEN '-3800.99 TO -3701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3700.99 AND-3601.00\r\n                                         THEN '-3700.99 TO -3601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3600.99 AND-3501.00\r\n                                         THEN '-3600.99 TO -3501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3500.99 AND-3401.00\r\n                                         THEN '-3500.99 TO -3401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3400.99 AND-3301.00\r\n                                         THEN '-3400.99 TO -3301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3300.99 AND-3201.00\r\n                                         THEN '-3300.99 TO -3201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3200.99 AND-3101.00\r\n                                         THEN '-3200.99 TO -3101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3100.99 AND-3001.00\r\n                                         THEN '-3100.99 TO -3001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3000.99 AND-2901.00\r\n                                         THEN '-3000.99 TO -2901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2900.99 AND-2801.00\r\n                                         THEN '-2900.99 TO -2801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2800.99 AND-2701.00\r\n                                         THEN '-2800.99 TO -2701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2700.99 AND-2601.00\r\n                                         THEN '-2700.99 TO -2601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2600.99 AND-2501.00\r\n                                         THEN '-2600.99 TO -2501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2500.99 AND-2401.00\r\n                                         THEN '-2500.99 TO -2401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2400.99 AND-2301.00\r\n                                         THEN '-2400.99 TO -2301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2300.99 AND-2201.00\r\n                                         THEN '-2300.99 TO -2201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2200.99 AND-2101.00\r\n                                         THEN '-2200.99 TO -2101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2100.99 AND-2001.00\r\n                                         THEN '-2100.99 TO -2001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2000.99 AND-1901.00\r\n                                         THEN '-2000.99 TO -1901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1900.99 AND-1801.00\r\n                                         THEN '-1900.99 TO -1801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1800.99 AND-1701.00\r\n                                         THEN '-1800.99 TO -1701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1700.99 AND-1601.00\r\n                                         THEN '-1700.99 TO -1601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1600.99 AND-1501.00\r\n                                         THEN '-1600.99 TO -1501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1500.99 AND-1401.00\r\n                                         THEN '-1500.99 TO -1401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1400.99 AND-1301.00\r\n                                         THEN '-1400.99 TO -1301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1300.99 AND-1201.00\r\n                                         THEN '-1300.99 TO -1201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1200.99 AND-1101.00\r\n                                         THEN '-1200.99 TO -1101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1100.99 AND-1001.00\r\n                                         THEN '-1100.99 TO -1001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1000.99 AND-901.00\r\n                                         THEN '-1000.99 TO -901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-900.99 AND-801.00\r\n                                         THEN '-900.99 TO -801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-800.99 AND-701.00\r\n                                         THEN '-800.99 TO -701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-700.99 AND-601.00\r\n                                         THEN '-700.99 TO -601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-600.99 AND-501.00\r\n                                         THEN '-600.99 TO -501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-500.99 AND-401.00\r\n                                         THEN '-500.99 TO -401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-400.99 AND-301.00\r\n                                         THEN '-400.99 TO -301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-300.99 AND-201.00\r\n                                         THEN '-300.99 TO -201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-200.99 AND-101.00\r\n                                         THEN '-200.99 TO -101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-199.99 AND-1.00\r\n                                         THEN '-100.99 TO -1.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-0.99 AND-0.01\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 0.00 AND 0.99\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1.00 AND 100.99\r\n                                         THEN '1.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 101.00 AND 200.99\r\n                                         THEN '101.00 TO 200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 201.00 AND 300.99\r\n                                         THEN '201.00 TO 300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 301.00 AND 400.99\r\n                                         THEN '301.00 TO 400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 401.00 AND 500.99\r\n                                         THEN '401.00 TO 500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 501.00 AND 600.99\r\n                                         THEN '501.00 TO 600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 601.00 AND 700.99\r\n                                         THEN '601.00 TO 700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 701.00 AND 800.99\r\n                                         THEN '701.00 TO 800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 801.00 AND 900.99\r\n                                         THEN '801.00 TO 900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 901.00 AND 1000.99\r\n                                         THEN '901.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1001.00 AND 1100.99\r\n                                         THEN '1000.00 TO 1100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1101.00 AND 1200.99\r\n                                         THEN '1101.00 TO 1200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1201.00 AND 1300.99\r\n                                         THEN '1201.00 TO 1300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1301.00 AND 1400.99\r\n                                         THEN '1301.00 TO 1400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1401.00 AND 1500.99\r\n                                         THEN '1401.00 TO 1500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1501.00 AND 1600.99\r\n                                         THEN '1501.00 TO 1600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1601.00 AND 1700.99\r\n                                         THEN '1601.00 TO 1700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1701.00 AND 1800.99\r\n                                         THEN '1701.00 TO 1800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1801.00 AND 1900.99\r\n                                         THEN '1801.00 TO 1900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1901.00 AND 2000.99\r\n                                         THEN '1901.00 TO 2000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2001.00 AND 2100.99\r\n                                         THEN '2001.00 TO 2100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2101.00 AND 2200.99\r\n                                         THEN '2101.00 TO 2200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2201.00 AND 2300.99\r\n                                         THEN '2201.00 TO 2300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2301.00 AND 2400.99\r\n                                         THEN '2301.00 TO 2400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2401.00 AND 2500.99\r\n                                         THEN '2401.00 TO 2500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2501.00 AND 2600.99\r\n                                         THEN '2501.00 TO 2600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2601.00 AND 2700.99\r\n                                         THEN '2601.00 TO 2700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2701.00 AND 2800.99\r\n                                         THEN '2701.00 TO 2800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2801.00 AND 2900.99\r\n                                         THEN '2801.00 TO 2900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2901.00 AND 3000.99\r\n                                         THEN '2901.00 TO 3000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3001.00 AND 3100.99\r\n                                         THEN '3000.00 TO 3100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3101.00 AND 3200.99\r\n                                         THEN '3101.00 TO 3200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3201.00 AND 3300.99\r\n                                         THEN '3201.00 TO 3300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3301.00 AND 3400.99\r\n                                         THEN '3301.00 TO 3400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3401.00 AND 3500.99\r\n                                         THEN '3401.00 TO 3500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3501.00 AND 3600.99\r\n                                         THEN '3501.00 TO 3600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3601.00 AND 3700.99\r\n                                         THEN '3601.00 TO 3700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3701.00 AND 3800.99\r\n                                         THEN '3701.00 TO 3800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3801.00 AND 3900.99\r\n                                         THEN '3801.00 TO 3900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3901.00 AND 4000.99\r\n                                         THEN '3901.00 TO 4000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4001.00 AND 4100.99\r\n                                         THEN '4000.00 TO 4100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4101.00 AND 4200.99\r\n                                         THEN '4101.00 TO 4200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4201.00 AND 4300.99\r\n                                         THEN '4201.00 TO 4300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4301.00 AND 4400.99\r\n                                         THEN '4301.00 TO 4400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4401.00 AND 4500.99\r\n                                         THEN '4401.00 TO 4500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4501.00 AND 4600.99\r\n                                         THEN '4501.00 TO 4600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4601.00 AND 4700.99\r\n                                         THEN '4601.00 TO 4700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4701.00 AND 4800.99\r\n                                         THEN '4701.00 TO 4800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4801.00 AND 4900.99\r\n                                         THEN '4801.00 TO 4900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4901.00 AND 5000.99\r\n                                         THEN '4901.00 TO 5000.99'\r\n                                         ELSE(CASE\r\n                                                  WHEN TotalAcquisItionCost >= 5000.99\r\n                                                  THEN '5000 +'\r\n                                              END)\r\n                                     END) AS Acquisition_Cost_Range\r\n    FROM\r\n    (\r\n        SELECT DISTINCT TOP (100) PERCENT Veh.StockTicketNumber, \r\n                                          INV.DateCreated, \r\n                                          Veh.ModelYear, \r\n                                          Veh.ModelName AS Model, \r\n                                          ISNULL(DATEDIFF(day, Veh.DatePhysicallyAcquired, GETDATE()), 0) AS AgeInDays, \r\n                                          ISNULL(VR.TotalRev, 0) AS GrossRevenue, \r\n                                          ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0) AS TotalAcquisitionCost, \r\n                                          ISNULL(VR.TotalRev, 0) - (ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0)) AS NetRevenue\r\n        FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n             INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n             INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n             INNER JOIN VEHICLE AS Veh WITH(NOLOCK) ON Veh.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                       AND Veh.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                       AND Veh.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n             INNER JOIN STORE AS St ON St.StoreNumber = Veh.StoreNumber\r\n                                       AND St.YardNumber = Veh.YardNumber\r\n             LEFT OUTER JOIN VEHICLE_COST_PAYMENT AS VCP WITH(NOLOCK) ON Veh.StockTicketNumber = VCP.StockTicketNumber\r\n                                                                         AND Veh.StoreNumber = VCP.StoreNumber\r\n                                                                         AND Veh.YardNumber = VCP.YardNumber\r\n             LEFT OUTER JOIN EMPLOYEE AS emp WITH(NOLOCK) ON Veh.Buyer = emp.EmployeeID\r\n             LEFT OUTER JOIN\r\n        (\r\n            SELECT YardNumber, \r\n                   StoreNumber, \r\n                   StockTicketNumber, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS TotalRev, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) <= 89)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M1, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 90 AND 179)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M4, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 180 AND 269)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M7, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(day, V.DatePhysicallyAcquired, INV.DateCreated) >= 270)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M10\r\n            FROM VEHICLE AS veh WITH(NOLOCK)\r\n        ) AS VR ON Veh.YardNumber = VR.YardNumber\r\n                   AND Veh.StoreNumber = VR.StoreNumber\r\n                   AND Veh.StockTicketNumber = VR.StockTicketNumber\r\n        WHERE(DATEDIFF(DD, INV.DateCreated, GETDATE()) BETWEEN 0 AND 180)\r\n             AND (Veh.StoreNumber = 5)\r\n        ORDER BY TotalAcquisitionCost DESC\r\n    ) AS SUBSET--) AS FINALSET\r\n    WHERE Model > '' AND TotalAcquisitionCost >0\r\n    ORDER BY TotalAcquisitionCost ASC\r\n) AS FINALSET\r\nGROUP BY $__timeGroup(DateCreated, '1d') , \r\n\r\nAcquisition_Cost_Range\r\nORDER BY  \r\n\r\n--DateCreated ASC\r\n$__timeGroup(DateCreated, '1d') ASC",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Vehicle Count and Percentage By Acquisition Cost Range Over Six Months",
      "type": "grafana-piechart-panel",
      "valueName": "total"
    },
    {
      "aliasColors": {},
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Others",
        "threshold": 0
      },
      "datasource": "${DS_POWERLINK}",
      "decimals": 2,
      "description": "",
      "fontSize": "80%",
      "format": "none",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 14
      },
      "id": 4,
      "interval": "",
      "legend": {
        "header": "",
        "percentage": true,
        "percentageDecimals": 2,
        "show": true,
        "sort": "total",
        "sortDesc": true,
        "values": true
      },
      "legendType": "Right side",
      "links": [],
      "maxDataPoints": 3,
      "nullPointMode": "connected",
      "options": {},
      "pieType": "pie",
      "strokeWidth": 1,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "rawSql": "\r\nSELECT \r\n\r\n--MAX(DateCreated) AS DateCreated,\r\n$__timeGroup(DateCreated, '1d') AS time,  \r\nMAX(Acquisition_Cost_Range) AS Acquisition_Cost_Range, \r\n      --COUNT(STOCKTICKETNUMBER) AS VEHICLE_COUNT\r\n\r\n       --MAX(MODELYEAR) AS MODELYEAR,\r\n       --MAX(MODEL) AS MODEL,\r\n       --MAX(AGEINDAYS) AS AGEINDAYS,\r\n       --SUM(GROSSREVENUE) AS GROSSREVENUE,\r\n       SUM(TOTALACQUISITIONCOST) AS TOTALACQUISITIONCOST\r\n       --ROUND(CONVERT(MONEY, SUM(NETREVENUE)), 2) AS NETREVENUE\r\nFROM\r\n(\r\n    SELECT DISTINCT TOP 100 PERCENT StockTicketNumber, \r\n                                    DateCreated,\r\n                                    ModelYear, \r\n                                    Model, \r\n                                    AgeInDays, \r\n                                    GrossRevenue, \r\n                                    TotalAcquisitionCost, \r\n                                    NetRevenue, \r\n                                    (CASE\r\n                                         WHEN TotalAcquisItionCost * 1.00 <= -5001.00\r\n                                         THEN '-5000.00 +'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-5000.99 AND-4901.00\r\n                                         THEN '-5000.99 TO -4901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4900.99 AND-4801.00\r\n                                         THEN '-4900.99 TO -4801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4800.99 AND-4701.00\r\n                                         THEN '-4800.99 TO -4701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4700.99 AND-4601.00\r\n                                         THEN '-4700.99 TO -4601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4600.99 AND-4501.00\r\n                                         THEN '-4600.99 TO -4501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4500.99 AND-4401.00\r\n                                         THEN '-4500.99 TO -4401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4400.99 AND-4301.00\r\n                                         THEN '-4400.99 TO -4301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4300.99 AND-4201.00\r\n                                         THEN '-4300.99 TO -4201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4200.99 AND-4101.00\r\n                                         THEN '-4200.99 TO -4101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4100.99 AND-4001.00\r\n                                         THEN '-4100.99 TO -4001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4000.99 AND-3901.00\r\n                                         THEN '-4000.99 TO -3901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3900.99 AND-3801.00\r\n                                         THEN '-3900.99 TO -3801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3800.99 AND-3701.00\r\n                                         THEN '-3800.99 TO -3701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3700.99 AND-3601.00\r\n                                         THEN '-3700.99 TO -3601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3600.99 AND-3501.00\r\n                                         THEN '-3600.99 TO -3501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3500.99 AND-3401.00\r\n                                         THEN '-3500.99 TO -3401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3400.99 AND-3301.00\r\n                                         THEN '-3400.99 TO -3301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3300.99 AND-3201.00\r\n                                         THEN '-3300.99 TO -3201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3200.99 AND-3101.00\r\n                                         THEN '-3200.99 TO -3101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3100.99 AND-3001.00\r\n                                         THEN '-3100.99 TO -3001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3000.99 AND-2901.00\r\n                                         THEN '-3000.99 TO -2901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2900.99 AND-2801.00\r\n                                         THEN '-2900.99 TO -2801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2800.99 AND-2701.00\r\n                                         THEN '-2800.99 TO -2701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2700.99 AND-2601.00\r\n                                         THEN '-2700.99 TO -2601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2600.99 AND-2501.00\r\n                                         THEN '-2600.99 TO -2501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2500.99 AND-2401.00\r\n                                         THEN '-2500.99 TO -2401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2400.99 AND-2301.00\r\n                                         THEN '-2400.99 TO -2301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2300.99 AND-2201.00\r\n                                         THEN '-2300.99 TO -2201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2200.99 AND-2101.00\r\n                                         THEN '-2200.99 TO -2101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2100.99 AND-2001.00\r\n                                         THEN '-2100.99 TO -2001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2000.99 AND-1901.00\r\n                                         THEN '-2000.99 TO -1901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1900.99 AND-1801.00\r\n                                         THEN '-1900.99 TO -1801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1800.99 AND-1701.00\r\n                                         THEN '-1800.99 TO -1701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1700.99 AND-1601.00\r\n                                         THEN '-1700.99 TO -1601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1600.99 AND-1501.00\r\n                                         THEN '-1600.99 TO -1501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1500.99 AND-1401.00\r\n                                         THEN '-1500.99 TO -1401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1400.99 AND-1301.00\r\n                                         THEN '-1400.99 TO -1301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1300.99 AND-1201.00\r\n                                         THEN '-1300.99 TO -1201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1200.99 AND-1101.00\r\n                                         THEN '-1200.99 TO -1101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1100.99 AND-1001.00\r\n                                         THEN '-1100.99 TO -1001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1000.99 AND-901.00\r\n                                         THEN '-1000.99 TO -901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-900.99 AND-801.00\r\n                                         THEN '-900.99 TO -801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-800.99 AND-701.00\r\n                                         THEN '-800.99 TO -701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-700.99 AND-601.00\r\n                                         THEN '-700.99 TO -601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-600.99 AND-501.00\r\n                                         THEN '-600.99 TO -501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-500.99 AND-401.00\r\n                                         THEN '-500.99 TO -401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-400.99 AND-301.00\r\n                                         THEN '-400.99 TO -301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-300.99 AND-201.00\r\n                                         THEN '-300.99 TO -201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-200.99 AND-101.00\r\n                                         THEN '-200.99 TO -101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-199.99 AND-1.00\r\n                                         THEN '-100.99 TO -1.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-0.99 AND-0.01\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 0.00 AND 0.99\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1.00 AND 100.99\r\n                                         THEN '1.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 101.00 AND 200.99\r\n                                         THEN '101.00 TO 200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 201.00 AND 300.99\r\n                                         THEN '201.00 TO 300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 301.00 AND 400.99\r\n                                         THEN '301.00 TO 400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 401.00 AND 500.99\r\n                                         THEN '401.00 TO 500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 501.00 AND 600.99\r\n                                         THEN '501.00 TO 600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 601.00 AND 700.99\r\n                                         THEN '601.00 TO 700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 701.00 AND 800.99\r\n                                         THEN '701.00 TO 800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 801.00 AND 900.99\r\n                                         THEN '801.00 TO 900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 901.00 AND 1000.99\r\n                                         THEN '901.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1001.00 AND 1100.99\r\n                                         THEN '1000.00 TO 1100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1101.00 AND 1200.99\r\n                                         THEN '1101.00 TO 1200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1201.00 AND 1300.99\r\n                                         THEN '1201.00 TO 1300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1301.00 AND 1400.99\r\n                                         THEN '1301.00 TO 1400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1401.00 AND 1500.99\r\n                                         THEN '1401.00 TO 1500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1501.00 AND 1600.99\r\n                                         THEN '1501.00 TO 1600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1601.00 AND 1700.99\r\n                                         THEN '1601.00 TO 1700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1701.00 AND 1800.99\r\n                                         THEN '1701.00 TO 1800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1801.00 AND 1900.99\r\n                                         THEN '1801.00 TO 1900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1901.00 AND 2000.99\r\n                                         THEN '1901.00 TO 2000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2001.00 AND 2100.99\r\n                                         THEN '2001.00 TO 2100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2101.00 AND 2200.99\r\n                                         THEN '2101.00 TO 2200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2201.00 AND 2300.99\r\n                                         THEN '2201.00 TO 2300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2301.00 AND 2400.99\r\n                                         THEN '2301.00 TO 2400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2401.00 AND 2500.99\r\n                                         THEN '2401.00 TO 2500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2501.00 AND 2600.99\r\n                                         THEN '2501.00 TO 2600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2601.00 AND 2700.99\r\n                                         THEN '2601.00 TO 2700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2701.00 AND 2800.99\r\n                                         THEN '2701.00 TO 2800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2801.00 AND 2900.99\r\n                                         THEN '2801.00 TO 2900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2901.00 AND 3000.99\r\n                                         THEN '2901.00 TO 3000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3001.00 AND 3100.99\r\n                                         THEN '3000.00 TO 3100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3101.00 AND 3200.99\r\n                                         THEN '3101.00 TO 3200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3201.00 AND 3300.99\r\n                                         THEN '3201.00 TO 3300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3301.00 AND 3400.99\r\n                                         THEN '3301.00 TO 3400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3401.00 AND 3500.99\r\n                                         THEN '3401.00 TO 3500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3501.00 AND 3600.99\r\n                                         THEN '3501.00 TO 3600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3601.00 AND 3700.99\r\n                                         THEN '3601.00 TO 3700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3701.00 AND 3800.99\r\n                                         THEN '3701.00 TO 3800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3801.00 AND 3900.99\r\n                                         THEN '3801.00 TO 3900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3901.00 AND 4000.99\r\n                                         THEN '3901.00 TO 4000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4001.00 AND 4100.99\r\n                                         THEN '4000.00 TO 4100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4101.00 AND 4200.99\r\n                                         THEN '4101.00 TO 4200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4201.00 AND 4300.99\r\n                                         THEN '4201.00 TO 4300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4301.00 AND 4400.99\r\n                                         THEN '4301.00 TO 4400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4401.00 AND 4500.99\r\n                                         THEN '4401.00 TO 4500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4501.00 AND 4600.99\r\n                                         THEN '4501.00 TO 4600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4601.00 AND 4700.99\r\n                                         THEN '4601.00 TO 4700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4701.00 AND 4800.99\r\n                                         THEN '4701.00 TO 4800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4801.00 AND 4900.99\r\n                                         THEN '4801.00 TO 4900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4901.00 AND 5000.99\r\n                                         THEN '4901.00 TO 5000.99'\r\n                                         ELSE(CASE\r\n                                                  WHEN TotalAcquisItionCost >= 5000.99\r\n                                                  THEN '5000 +'\r\n                                              END)\r\n                                     END) AS Acquisition_Cost_Range\r\n    FROM\r\n    (\r\n        SELECT DISTINCT TOP (100) PERCENT Veh.StockTicketNumber, \r\n                                          INV.DateCreated, \r\n                                          Veh.ModelYear, \r\n                                          Veh.ModelName AS Model, \r\n                                          ISNULL(DATEDIFF(day, Veh.DatePhysicallyAcquired, GETDATE()), 0) AS AgeInDays, \r\n                                          ISNULL(VR.TotalRev, 0) AS GrossRevenue, \r\n                                          ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0) AS TotalAcquisitionCost, \r\n                                          ISNULL(VR.TotalRev, 0) - (ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0)) AS NetRevenue\r\n        FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n             INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n             INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n             INNER JOIN VEHICLE AS Veh WITH(NOLOCK) ON Veh.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                       AND Veh.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                       AND Veh.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n             INNER JOIN STORE AS St ON St.StoreNumber = Veh.StoreNumber\r\n                                       AND St.YardNumber = Veh.YardNumber\r\n             LEFT OUTER JOIN VEHICLE_COST_PAYMENT AS VCP WITH(NOLOCK) ON Veh.StockTicketNumber = VCP.StockTicketNumber\r\n                                                                         AND Veh.StoreNumber = VCP.StoreNumber\r\n                                                                         AND Veh.YardNumber = VCP.YardNumber\r\n             LEFT OUTER JOIN EMPLOYEE AS emp WITH(NOLOCK) ON Veh.Buyer = emp.EmployeeID\r\n             LEFT OUTER JOIN\r\n        (\r\n            SELECT YardNumber, \r\n                   StoreNumber, \r\n                   StockTicketNumber, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS TotalRev, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) <= 89)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M1, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 90 AND 179)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M4, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 180 AND 269)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M7, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(day, V.DatePhysicallyAcquired, INV.DateCreated) >= 270)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M10\r\n            FROM VEHICLE AS veh WITH(NOLOCK)\r\n        ) AS VR ON Veh.YardNumber = VR.YardNumber\r\n                   AND Veh.StoreNumber = VR.StoreNumber\r\n                   AND Veh.StockTicketNumber = VR.StockTicketNumber\r\n        WHERE(DATEDIFF(DD, INV.DateCreated, GETDATE()) BETWEEN 0 AND 180)\r\n             AND (Veh.StoreNumber = 5)\r\n        ORDER BY TotalAcquisitionCost DESC\r\n    ) AS SUBSET--) AS FINALSET\r\n    WHERE Model > '' AND TotalAcquisitionCost >0\r\n    ORDER BY TotalAcquisitionCost ASC\r\n) AS FINALSET\r\nGROUP BY $__timeGroup(DateCreated, '1d') , \r\n\r\nAcquisition_Cost_Range\r\nORDER BY  \r\n\r\n--DateCreated ASC\r\n$__timeGroup(DateCreated, '1d') ASC",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Total Acquisition Cost Dollars and Percentages Over Six Months",
      "type": "grafana-piechart-panel",
      "valueName": "total"
    },
    {
      "aliasColors": {
        "Count": "green"
      },
      "bars": false,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_POWERLINK}",
      "decimals": 2,
      "description": "",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 14
      },
      "id": 2,
      "interval": "",
      "legend": {
        "alignAsTable": true,
        "avg": true,
        "current": false,
        "hideEmpty": true,
        "hideZero": true,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "sideWidth": null,
        "sort": "total",
        "sortDesc": true,
        "total": true,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pluginVersion": "6.4.4",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "rawSql": "\r\nSELECT \r\n\r\n--MAX(DateCreated) AS DateCreated,\r\n$__timeGroup(DateCreated, '1d') AS time,  \r\nMAX(Acquisition_Cost_Range) AS Acquisition_Cost_Range, \r\n      --COUNT(STOCKTICKETNUMBER) AS VEHICLE_COUNT\r\n\r\n       --MAX(MODELYEAR) AS MODELYEAR,\r\n       --MAX(MODEL) AS MODEL,\r\n       --MAX(AGEINDAYS) AS AGEINDAYS,\r\n       --SUM(GROSSREVENUE) AS GROSSREVENUE,\r\n       --SUM(TOTALACQUISITIONCOST) AS TOTALACQUISITIONCOST,\r\n       ROUND(CONVERT(MONEY, SUM(NETREVENUE)), 2) AS NETREVENUE\r\nFROM\r\n(\r\n    SELECT DISTINCT TOP 100 PERCENT StockTicketNumber, \r\n                                    DateCreated,\r\n                                    ModelYear, \r\n                                    Model, \r\n                                    AgeInDays, \r\n                                    GrossRevenue, \r\n                                    TotalAcquisitionCost, \r\n                                    NetRevenue, \r\n                                    (CASE\r\n                                         WHEN TotalAcquisItionCost * 1.00 <= -5001.00\r\n                                         THEN '-5000.00 +'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-5000.99 AND-4901.00\r\n                                         THEN '-5000.99 TO -4901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4900.99 AND-4801.00\r\n                                         THEN '-4900.99 TO -4801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4800.99 AND-4701.00\r\n                                         THEN '-4800.99 TO -4701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4700.99 AND-4601.00\r\n                                         THEN '-4700.99 TO -4601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4600.99 AND-4501.00\r\n                                         THEN '-4600.99 TO -4501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4500.99 AND-4401.00\r\n                                         THEN '-4500.99 TO -4401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4400.99 AND-4301.00\r\n                                         THEN '-4400.99 TO -4301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4300.99 AND-4201.00\r\n                                         THEN '-4300.99 TO -4201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4200.99 AND-4101.00\r\n                                         THEN '-4200.99 TO -4101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4100.99 AND-4001.00\r\n                                         THEN '-4100.99 TO -4001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-4000.99 AND-3901.00\r\n                                         THEN '-4000.99 TO -3901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3900.99 AND-3801.00\r\n                                         THEN '-3900.99 TO -3801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3800.99 AND-3701.00\r\n                                         THEN '-3800.99 TO -3701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3700.99 AND-3601.00\r\n                                         THEN '-3700.99 TO -3601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3600.99 AND-3501.00\r\n                                         THEN '-3600.99 TO -3501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3500.99 AND-3401.00\r\n                                         THEN '-3500.99 TO -3401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3400.99 AND-3301.00\r\n                                         THEN '-3400.99 TO -3301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3300.99 AND-3201.00\r\n                                         THEN '-3300.99 TO -3201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3200.99 AND-3101.00\r\n                                         THEN '-3200.99 TO -3101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3100.99 AND-3001.00\r\n                                         THEN '-3100.99 TO -3001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-3000.99 AND-2901.00\r\n                                         THEN '-3000.99 TO -2901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2900.99 AND-2801.00\r\n                                         THEN '-2900.99 TO -2801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2800.99 AND-2701.00\r\n                                         THEN '-2800.99 TO -2701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2700.99 AND-2601.00\r\n                                         THEN '-2700.99 TO -2601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2600.99 AND-2501.00\r\n                                         THEN '-2600.99 TO -2501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2500.99 AND-2401.00\r\n                                         THEN '-2500.99 TO -2401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2400.99 AND-2301.00\r\n                                         THEN '-2400.99 TO -2301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2300.99 AND-2201.00\r\n                                         THEN '-2300.99 TO -2201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2200.99 AND-2101.00\r\n                                         THEN '-2200.99 TO -2101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2100.99 AND-2001.00\r\n                                         THEN '-2100.99 TO -2001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-2000.99 AND-1901.00\r\n                                         THEN '-2000.99 TO -1901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1900.99 AND-1801.00\r\n                                         THEN '-1900.99 TO -1801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1800.99 AND-1701.00\r\n                                         THEN '-1800.99 TO -1701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1700.99 AND-1601.00\r\n                                         THEN '-1700.99 TO -1601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1600.99 AND-1501.00\r\n                                         THEN '-1600.99 TO -1501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1500.99 AND-1401.00\r\n                                         THEN '-1500.99 TO -1401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1400.99 AND-1301.00\r\n                                         THEN '-1400.99 TO -1301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1300.99 AND-1201.00\r\n                                         THEN '-1300.99 TO -1201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1200.99 AND-1101.00\r\n                                         THEN '-1200.99 TO -1101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1100.99 AND-1001.00\r\n                                         THEN '-1100.99 TO -1001.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-1000.99 AND-901.00\r\n                                         THEN '-1000.99 TO -901.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-900.99 AND-801.00\r\n                                         THEN '-900.99 TO -801.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-800.99 AND-701.00\r\n                                         THEN '-800.99 TO -701.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-700.99 AND-601.00\r\n                                         THEN '-700.99 TO -601.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-600.99 AND-501.00\r\n                                         THEN '-600.99 TO -501.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-500.99 AND-401.00\r\n                                         THEN '-500.99 TO -401.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-400.99 AND-301.00\r\n                                         THEN '-400.99 TO -301.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-300.99 AND-201.00\r\n                                         THEN '-300.99 TO -201.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-200.99 AND-101.00\r\n                                         THEN '-200.99 TO -101.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-199.99 AND-1.00\r\n                                         THEN '-100.99 TO -1.00'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN-0.99 AND-0.01\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 0.00 AND 0.99\r\n                                         THEN '0'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1.00 AND 100.99\r\n                                         THEN '1.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 101.00 AND 200.99\r\n                                         THEN '101.00 TO 200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 201.00 AND 300.99\r\n                                         THEN '201.00 TO 300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 301.00 AND 400.99\r\n                                         THEN '301.00 TO 400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 401.00 AND 500.99\r\n                                         THEN '401.00 TO 500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 501.00 AND 600.99\r\n                                         THEN '501.00 TO 600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 601.00 AND 700.99\r\n                                         THEN '601.00 TO 700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 701.00 AND 800.99\r\n                                         THEN '701.00 TO 800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 801.00 AND 900.99\r\n                                         THEN '801.00 TO 900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 901.00 AND 1000.99\r\n                                         THEN '901.00 TO 100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1001.00 AND 1100.99\r\n                                         THEN '1000.00 TO 1100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1101.00 AND 1200.99\r\n                                         THEN '1101.00 TO 1200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1201.00 AND 1300.99\r\n                                         THEN '1201.00 TO 1300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1301.00 AND 1400.99\r\n                                         THEN '1301.00 TO 1400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1401.00 AND 1500.99\r\n                                         THEN '1401.00 TO 1500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1501.00 AND 1600.99\r\n                                         THEN '1501.00 TO 1600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1601.00 AND 1700.99\r\n                                         THEN '1601.00 TO 1700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1701.00 AND 1800.99\r\n                                         THEN '1701.00 TO 1800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1801.00 AND 1900.99\r\n                                         THEN '1801.00 TO 1900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 1901.00 AND 2000.99\r\n                                         THEN '1901.00 TO 2000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2001.00 AND 2100.99\r\n                                         THEN '2001.00 TO 2100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2101.00 AND 2200.99\r\n                                         THEN '2101.00 TO 2200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2201.00 AND 2300.99\r\n                                         THEN '2201.00 TO 2300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2301.00 AND 2400.99\r\n                                         THEN '2301.00 TO 2400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2401.00 AND 2500.99\r\n                                         THEN '2401.00 TO 2500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2501.00 AND 2600.99\r\n                                         THEN '2501.00 TO 2600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2601.00 AND 2700.99\r\n                                         THEN '2601.00 TO 2700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2701.00 AND 2800.99\r\n                                         THEN '2701.00 TO 2800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2801.00 AND 2900.99\r\n                                         THEN '2801.00 TO 2900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 2901.00 AND 3000.99\r\n                                         THEN '2901.00 TO 3000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3001.00 AND 3100.99\r\n                                         THEN '3000.00 TO 3100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3101.00 AND 3200.99\r\n                                         THEN '3101.00 TO 3200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3201.00 AND 3300.99\r\n                                         THEN '3201.00 TO 3300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3301.00 AND 3400.99\r\n                                         THEN '3301.00 TO 3400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3401.00 AND 3500.99\r\n                                         THEN '3401.00 TO 3500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3501.00 AND 3600.99\r\n                                         THEN '3501.00 TO 3600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3601.00 AND 3700.99\r\n                                         THEN '3601.00 TO 3700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3701.00 AND 3800.99\r\n                                         THEN '3701.00 TO 3800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3801.00 AND 3900.99\r\n                                         THEN '3801.00 TO 3900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 3901.00 AND 4000.99\r\n                                         THEN '3901.00 TO 4000.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4001.00 AND 4100.99\r\n                                         THEN '4000.00 TO 4100.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4101.00 AND 4200.99\r\n                                         THEN '4101.00 TO 4200.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4201.00 AND 4300.99\r\n                                         THEN '4201.00 TO 4300.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4301.00 AND 4400.99\r\n                                         THEN '4301.00 TO 4400.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4401.00 AND 4500.99\r\n                                         THEN '4401.00 TO 4500.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4501.00 AND 4600.99\r\n                                         THEN '4501.00 TO 4600.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4601.00 AND 4700.99\r\n                                         THEN '4601.00 TO 4700.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4701.00 AND 4800.99\r\n                                         THEN '4701.00 TO 4800.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4801.00 AND 4900.99\r\n                                         THEN '4801.00 TO 4900.99'\r\n                                         WHEN(TotalAcquisItionCost * 1.00) BETWEEN 4901.00 AND 5000.99\r\n                                         THEN '4901.00 TO 5000.99'\r\n                                         ELSE(CASE\r\n                                                  WHEN TotalAcquisItionCost >= 5000.99\r\n                                                  THEN '5000 +'\r\n                                              END)\r\n                                     END) AS Acquisition_Cost_Range\r\n    FROM\r\n    (\r\n        SELECT DISTINCT TOP (100) PERCENT Veh.StockTicketNumber, \r\n                                          INV.DateCreated, \r\n                                          Veh.ModelYear, \r\n                                          Veh.ModelName AS Model, \r\n                                          ISNULL(DATEDIFF(day, Veh.DatePhysicallyAcquired, GETDATE()), 0) AS AgeInDays, \r\n                                          ISNULL(VR.TotalRev, 0) AS GrossRevenue, \r\n                                          ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0) AS TotalAcquisitionCost, \r\n                                          ISNULL(VR.TotalRev, 0) - (ISNULL(Veh.BreakEvenDays, 0) + ISNULL(VCP.VehicleSalvageCost, 0) + ISNULL(VCP.ProcessingCommissionCost, 0) + ISNULL(VCP.PoolCost, 0) + ISNULL(VCP.PoolBuyerFee, 0) + ISNULL(VCP.TitleTransferCost, 0) + ISNULL(VCP.TowingStorageCost, 0) + ISNULL(VCP.PoolLoadingCost, 0) + ISNULL(VCP.InboundTowingCost, 0) + ISNULL(VCP.ProcessingCost, 0) + ISNULL(VCP.OtherCost, 0)) AS NetRevenue\r\n        FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n             INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n             INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n             INNER JOIN VEHICLE AS Veh WITH(NOLOCK) ON Veh.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                       AND Veh.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                       AND Veh.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n             INNER JOIN STORE AS St ON St.StoreNumber = Veh.StoreNumber\r\n                                       AND St.YardNumber = Veh.YardNumber\r\n             LEFT OUTER JOIN VEHICLE_COST_PAYMENT AS VCP WITH(NOLOCK) ON Veh.StockTicketNumber = VCP.StockTicketNumber\r\n                                                                         AND Veh.StoreNumber = VCP.StoreNumber\r\n                                                                         AND Veh.YardNumber = VCP.YardNumber\r\n             LEFT OUTER JOIN EMPLOYEE AS emp WITH(NOLOCK) ON Veh.Buyer = emp.EmployeeID\r\n             LEFT OUTER JOIN\r\n        (\r\n            SELECT YardNumber, \r\n                   StoreNumber, \r\n                   StockTicketNumber, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS TotalRev, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) <= 89)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M1, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 90 AND 179)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M4, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(Day, V.DatePhysicallyAcquired, INV.DateCreated) BETWEEN 180 AND 269)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M7, \r\n                   ISNULL(\r\n            (\r\n                SELECT ISNULL(SUM(CASE\r\n                                      WHEN InvLI.LineItemType IN('PART', 'RETN', 'CORE', 'CRET', 'CRED')\r\n                                      THEN(InvLI.UnitPrice * InvLI.Quantity) - InvLI.TotalDiscountAmount\r\n                                      ELSE 0\r\n                                  END), 0) AS Expr1\r\n                FROM INVOICE_LINEITEM AS InvLI WITH(NOLOCK)\r\n                     INNER JOIN INVENTORY AS Invtry WITH(NOLOCK) ON InvLI.InventoryID = Invtry.InventoryID\r\n                     INNER JOIN INVOICE AS INV WITH(NOLOCK) ON InvLI.InvoiceID = INV.InvoiceID\r\n                     INNER JOIN VEHICLE AS V WITH(NOLOCK) ON V.StockTicketNumber = Invtry.StockTicketNumber\r\n                                                             AND V.YardNumber = Invtry.SourceVehicleYardNumber\r\n                                                             AND V.StoreNumber = Invtry.SourceVehicleStoreNumber\r\n                WHERE(V.StockTicketNumber = veh.StockTicketNumber)\r\n                     AND (V.YardNumber = veh.YardNumber)\r\n                     AND (V.StoreNumber = veh.StoreNumber)\r\n                     AND (DATEDIFF(day, V.DatePhysicallyAcquired, INV.DateCreated) >= 270)\r\n                GROUP BY V.YardNumber, \r\n                         V.StoreNumber, \r\n                         V.StockTicketNumber\r\n            ), 0) AS M10\r\n            FROM VEHICLE AS veh WITH(NOLOCK)\r\n        ) AS VR ON Veh.YardNumber = VR.YardNumber\r\n                   AND Veh.StoreNumber = VR.StoreNumber\r\n                   AND Veh.StockTicketNumber = VR.StockTicketNumber\r\n        WHERE(DATEDIFF(DD, INV.DateCreated, GETDATE()) BETWEEN 0 AND 180)\r\n             AND (Veh.StoreNumber = 5)\r\n        ORDER BY TotalAcquisitionCost DESC\r\n    ) AS SUBSET--) AS FINALSET\r\n    WHERE Model > '' AND TotalAcquisitionCost >0\r\n    ORDER BY TotalAcquisitionCost ASC\r\n) AS FINALSET\r\nGROUP BY $__timeGroup(DateCreated, '1d') , \r\n\r\nAcquisition_Cost_Range\r\nORDER BY  \r\n\r\n--DateCreated ASC\r\n$__timeGroup(DateCreated, '1d') ASC",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Peak Vehicle Acquisition Cost To Net Profit Curve Over Six Months",
      "tooltip": {
        "shared": false,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": 100,
        "max": null,
        "min": null,
        "mode": "histogram",
        "name": null,
        "show": true,
        "values": [
          "total"
        ]
      },
      "yaxes": [
        {
          "decimals": 2,
          "format": "currencyUSD",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": 2,
          "format": "currencyUSD",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": true,
        "alignLevel": 0
      }
    }
  ],
  "schemaVersion": 20,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6M",
    "to": "now"
  },
  "timepicker": {
    "hidden": true,
    "refresh_intervals": [
      "5m"
    ]
  },
  "timezone": "",
  "title": "Peak Vehicle Acquisition Cost In 100$ Increments Over Six Months",
  "uid": "jkiVSq-Wk",
  "version": 43,
  "description": "Peak Vehicle Acquisition Cost in 100$ Increments Over Six Months"
}