sum over partition by函式的用法-但是查出來的資料格式不好給前臺用,廢棄

ZHOU_VIP發表於2017-04-18

要求:按車牌號HOST_NO分組,合計CAR_PAY金額,最後合計所有金額,還要過濾出本月的時間



說明:雖然查出來了,但是這種資料格式不好給前臺用,前臺要的是列表的格式


{
    "retCode":1,
    "retMsg":"操作成功",
    "list":[
        {
            "recordId":"20161201200445671015895",
            "carEtcNo":"測試0002",
            "carHostNO":"蘇AM10001",
            "carStartEtcTime":"2017-04-01 17:43:50",
            "carEndEtcTime":"2017-04-18 20:05:44",
            "carLine":"三牌樓--古林公園111",
            "carPay":10,
            "carProvince":"320000",
            "carProvinceDesc":"江蘇省"
        },
        {
            "carPay":10,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161129180514209018381",
            "carEtcNo":"1333333333",
            "carHostNO":"蘇A2002",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":66,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20161129180325044015371",
            "carEtcNo":"1333333333",
            "carHostNO":"蘇A2002",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":66,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20161129175757881014238",
            "carEtcNo":"1333333333",
            "carHostNO":"蘇A2002",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":14,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":146,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161129180513905010007",
            "carEtcNo":"1222222222",
            "carHostNO":"蘇A2001",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":88,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20161129180309437011679",
            "carEtcNo":"1222222222",
            "carHostNO":"蘇A2001",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":55,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":143,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20170323192547109019398",
            "carEtcNo":"ee94",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-01 12:12:12",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":16,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20170323192547121011329",
            "carEtcNo":"ee96",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-03 12:12:12",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":150,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20170323192547128013962",
            "carEtcNo":"ee97",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-02 12:12:12",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":100,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20170323192547134010071",
            "carEtcNo":"ee98",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-05 12:12:12",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":100,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20170323192547140018430",
            "carEtcNo":"ee99",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-20 12:12:12",
            "carEndEtcTime":"2017-04-25 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":100,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20170323192547147016616",
            "carEtcNo":"ee100",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-01 12:12:12",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":100,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "recordId":"20170323192547115010841",
            "carEtcNo":"ee95",
            "carHostNO":"人a1002",
            "carStartEtcTime":"2017-04-01 12:12:12",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":100,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":666,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161202101559495018075",
            "carEtcNo":"333",
            "carHostNO":"2900",
            "carStartEtcTime":"2017-04-01 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":44,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":44,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161130111132840016135",
            "carEtcNo":"2656",
            "carHostNO":"15000",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":15,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":15,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161202110607795014435",
            "carEtcNo":"003",
            "carHostNO":"14000",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-15 12:12:12",
            "carLine":"中山門到漢中門",
            "carPay":42,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":42,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161130183025739012483",
            "carEtcNo":"2",
            "carHostNO":"1301",
            "carStartEtcTime":"2017-04-01 17:43:50",
            "carEndEtcTime":"2017-04-23 18:47:04",
            "carLine":"中山門到漢中門",
            "carPay":87,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":87,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20170221091233259012244",
            "carEtcNo":"112233",
            "carHostNO":"1010",
            "carStartEtcTime":"2017-04-02 17:43:50",
            "carEndEtcTime":"2017-04-23 18:47:04",
            "carLine":"中山門到漢中門",
            "carPay":25,
            "carProvince":"230000",
            "carProvinceDesc":"黑龍江省"
        },
        {
            "carPay":25,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "recordId":"20161202110501256014722",
            "carEtcNo":"3",
            "carHostNO":"0213",
            "carStartEtcTime":"2017-04-01 17:43:50",
            "carEndEtcTime":"2017-04-23 18:47:04",
            "carLine":"中山門到漢中門",
            "carPay":10,
            "carProvince":"120000",
            "carProvinceDesc":"天津市"
        },
        {
            "carPay":10,
            "carProvince":"消費合計",
            "carProvinceDesc":""
        },
        {
            "carEtcNo":"合計",
            "carPay":1188
        }
    ]
}


參考:

http://blog.csdn.net/wawmg/article/details/40840093

相關文章