{
  "data": {
    "debug": {
      "durationMs": 4,
      "extra": {
        "aggSql": "WITH stage1 AS (\nselect\tstrftime('%Y-%m', t1.InvoiceDate) \"invoiceDate$yearMonth\",\tSUM(t1.Total) \"totalAmount\",\tCOUNT(t1.InvoiceId) \"billCount\",\tSUM(t1.Total) \"invoiceAmount\"\tfrom Invoice t1\t where  1=1  and \tt1.InvoiceDate >=?  and \tt1.InvoiceDate <? \tgroup by strftime('%Y-%m', t1.InvoiceDate)\n),\n__POST_RESULT_STAGE__ AS (\nSELECT stage1.\"invoiceDate$yearMonth\",\n       stage1.\"totalAmount\",\n       stage1.\"billCount\",\n       stage1.\"invoiceAmount\",\n       LAG(\"invoiceAmount\", 1) OVER (ORDER BY \"invoiceDate$yearMonth\" ASC) AS \"previousAmount\"\nFROM stage1\n),\nresult_calc_2 AS (\nSELECT __POST_RESULT_STAGE__.\"invoiceDate$yearMonth\",\n       __POST_RESULT_STAGE__.\"totalAmount\",\n       __POST_RESULT_STAGE__.\"billCount\",\n       __POST_RESULT_STAGE__.\"invoiceAmount\",\n       __POST_RESULT_STAGE__.\"previousAmount\",\n       (\"invoiceAmount\" - \"previousAmount\") AS \"difference\",\n       ((1e0 * (\"invoiceAmount\" - \"previousAmount\")) / NULLIF(NULLIF(\"previousAmount\", 0), 0)) AS \"changeRatio\"\nFROM __POST_RESULT_STAGE__\n)\nselect\tnull \"invoiceDate$yearMonth\",\tnull \"totalAmount\",\tnull \"billCount\",\tnull \"previousAmount\",\tnull \"difference\",\tnull \"changeRatio\",\tcount(*) \"total\"\tfrom (SELECT \"invoiceDate$yearMonth\" AS \"invoiceDate$yearMonth\",\n       \"totalAmount\" AS \"totalAmount\",\n       \"billCount\" AS \"billCount\",\n       \"previousAmount\" AS \"previousAmount\",\n       \"difference\" AS \"difference\",\n       \"changeRatio\" AS \"changeRatio\"\nFROM result_calc_2) tx\t",
        "params": [
          "2012-01-01",
          "2013-01-01"
        ],
        "sql": "WITH stage1 AS (\nselect\tstrftime('%Y-%m', t1.InvoiceDate) \"invoiceDate$yearMonth\",\tSUM(t1.Total) \"totalAmount\",\tCOUNT(t1.InvoiceId) \"billCount\",\tSUM(t1.Total) \"invoiceAmount\"\tfrom Invoice t1\t where  1=1  and \tt1.InvoiceDate >=?  and \tt1.InvoiceDate <? \tgroup by strftime('%Y-%m', t1.InvoiceDate)\n),\n__POST_RESULT_STAGE__ AS (\nSELECT stage1.\"invoiceDate$yearMonth\",\n       stage1.\"totalAmount\",\n       stage1.\"billCount\",\n       stage1.\"invoiceAmount\",\n       LAG(\"invoiceAmount\", 1) OVER (ORDER BY \"invoiceDate$yearMonth\" ASC) AS \"previousAmount\"\nFROM stage1\n),\nresult_calc_2 AS (\nSELECT __POST_RESULT_STAGE__.\"invoiceDate$yearMonth\",\n       __POST_RESULT_STAGE__.\"totalAmount\",\n       __POST_RESULT_STAGE__.\"billCount\",\n       __POST_RESULT_STAGE__.\"invoiceAmount\",\n       __POST_RESULT_STAGE__.\"previousAmount\",\n       (\"invoiceAmount\" - \"previousAmount\") AS \"difference\",\n       ((1e0 * (\"invoiceAmount\" - \"previousAmount\")) / NULLIF(NULLIF(\"previousAmount\", 0), 0)) AS \"changeRatio\"\nFROM __POST_RESULT_STAGE__\n)\nSELECT \"invoiceDate$yearMonth\" AS \"invoiceDate$yearMonth\",\n       \"totalAmount\" AS \"totalAmount\",\n       \"billCount\" AS \"billCount\",\n       \"previousAmount\" AS \"previousAmount\",\n       \"difference\" AS \"difference\",\n       \"changeRatio\" AS \"changeRatio\"\nFROM result_calc_2\nORDER BY \"invoiceDate$yearMonth\" asc"
      },
      "normalized": {
        "groupBy": [
          {
            "field": "invoiceDate$yearMonth"
          },
          {
            "agg": "SUM",
            "field": "totalAmount"
          },
          {
            "agg": "COUNT",
            "field": "billCount"
          },
          {
            "field": "previousAmount"
          },
          {
            "field": "difference"
          },
          {
            "field": "changeRatio"
          }
        ],
        "orderBy": [
          {
            "dir": "asc",
            "field": "invoiceDate$yearMonth",
            "nullFirst": false,
            "nullLast": false
          }
        ],
        "slice": [
          {
            "field": "invoiceDate$id",
            "op": "[)",
            "value": [
              "2012-01-01",
              "2013-01-01"
            ]
          }
        ]
      }
    },
    "hasNext": false,
    "items": [
      {
        "billCount": 7,
        "invoiceDate$yearMonth": "2012-01",
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.0,
        "difference": 0.0,
        "invoiceDate$yearMonth": "2012-02",
        "previousAmount": 37.62,
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.0,
        "difference": 0.0,
        "invoiceDate$yearMonth": "2012-03",
        "previousAmount": 37.62,
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.0,
        "difference": 0.0,
        "invoiceDate$yearMonth": "2012-04",
        "previousAmount": 37.62,
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.0,
        "difference": 0.0,
        "invoiceDate$yearMonth": "2012-05",
        "previousAmount": 37.62,
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.0,
        "difference": 0.0,
        "invoiceDate$yearMonth": "2012-06",
        "previousAmount": 37.62,
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.053163211057947905,
        "difference": 2.0,
        "invoiceDate$yearMonth": "2012-07",
        "previousAmount": 37.62,
        "totalAmount": 39.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.20191822311963656,
        "difference": 8.0,
        "invoiceDate$yearMonth": "2012-08",
        "previousAmount": 39.62,
        "totalAmount": 47.62
      },
      {
        "billCount": 6,
        "changeRatio": -0.019109617807643777,
        "difference": -0.9099999999999966,
        "invoiceDate$yearMonth": "2012-09",
        "previousAmount": 47.62,
        "totalAmount": 46.71
      },
      {
        "billCount": 7,
        "changeRatio": -0.08756154998929573,
        "difference": -4.090000000000003,
        "invoiceDate$yearMonth": "2012-10",
        "previousAmount": 46.71,
        "totalAmount": 42.62
      },
      {
        "billCount": 7,
        "changeRatio": -0.11731581417175035,
        "difference": -5.0,
        "invoiceDate$yearMonth": "2012-11",
        "previousAmount": 42.62,
        "totalAmount": 37.62
      },
      {
        "billCount": 7,
        "changeRatio": 0.0,
        "difference": 0.0,
        "invoiceDate$yearMonth": "2012-12",
        "previousAmount": 37.62,
        "totalAmount": 37.62
      }
    ],
    "pagination": {
      "hasMore": false,
      "limit": 100,
      "rangeDescription": "显示第 1-12 条",
      "returned": 12,
      "start": 0
    },
    "schema": {
      "columns": [
        {
          "dataType": "STRING",
          "name": "invoiceDate$yearMonth",
          "title": "账单年月"
        },
        {
          "name": "totalAmount"
        },
        {
          "name": "billCount"
        },
        {
          "name": "previousAmount"
        },
        {
          "name": "difference"
        },
        {
          "name": "changeRatio"
        }
      ],
      "summary": "按 账单年月、previousAmount、difference、changeRatio 分组，统计 totalAmount、billCount，返回 12 条数据"
    },
    "total": 0
  },
  "diagnostics": {
    "attributes": {},
    "warnings": []
  },
  "engine": "java",
  "runtimeApiVersion": "foggy-runtime-api/v1",
  "success": true
}
