我正在尝试使用order by子句......
我的代码......
db.rawQuery("select * from pd_data where item_type=1 and item_date like '%" + month + "%' order by date(item_date) DESC Limit 1", null);
但这只返回一个值......
我的日期格式dd MMM yyyy
。
我该如何解决这个问题..?
是否可以使用order by子句对dd MMM yyyy
日期格式进行排序..?
答案 0 :(得分:1)
"这只返回一个值",尝试在查询结束时删除peer0.proveedor.com | 2017-06-29 11:17:16.027 UTC [deliveryClient] StartDeliverForChannel -> DEBU 2d8 This peer will pass blocks from orderer service to other peers for channel canaltraza
orderer0.tec.com | 2017-06-29 11:17:16.031 UTC [orderer/main] Deliver -> DEBU c22 Starting new Deliver handler
orderer0.tec.com | 2017-06-29 11:17:16.031 UTC [orderer/common/deliver] Handle -> DEBU c23 Starting new deliver loop
orderer0.tec.com | 2017-06-29 11:17:16.031 UTC [orderer/common/deliver] Handle -> DEBU c24 Attempting to read seek info message
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [policies] GetPolicy -> DEBU c25 Returning policy Readers for evaluation
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func1 -> DEBU c26 0xc42010d530 gate 1498735036032103426 evaluation starts
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func2 -> DEBU c27 0xc42010d530 signed by 0 principal evaluation starts (used [false])
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func2 -> DEBU c28 0xc42010d530 processing identity 0 with bytes of 0a0950726f766565646f7212f4052d2d2d2d2d424547494e202d2d2d2d2d0a4d49494345444343416265674177494241674952414c595177764d593852483533594d4a7970767977457777436759494b6f5a497a6a3045417749776254454c0a4d416b474131554542684d4356564d78457a415242674e5642416754436b4e6862476c6d62334a7561574578466a415542674e564241635444564e68626942470a636d467559326c7a59323878466a415542674e5642416f544458427962335a6c5a5752766369356a623230784754415842674e5642414d5445474e684c6e42790a62335a6c5a5752766369356a623230774868634e4d5463774e6a49354d4467304d7a41335768634e4d6a63774e6a49334d4467304d7a4133576a42594d5173770a435159445651514745774a56557a45544d4245474131554543424d4b5132467361575a76636d3570595445574d4251474131554542784d4e5532467549455a790a5957356a61584e6a627a45634d426f474131554541784d546347566c636a417563484a76646d566c5a4739794c6d4e766254425a4d424d4742797147534d34390a4167454743437147534d34394177454841304941424b5137324e78684f744648354b62666876744e3068624a484f714d6c56734c37695262794e75626a5264630a785039784554507153313169492b33724b46336f4e622b7679777756555058376335653877616f2b6a46366a5454424c4d41344741315564447745422f7751450a417749486744414d42674e5648524d4241663845416a41414d437347413155644977516b4d434b4149496631483567312b535164576369307753386b536136370a45305a4d4651516944776f426a466978786d48434d416f4743437147534d343942414d43413063414d4551434945497a7451796f476e512f6d74334c685561640a3563585172415a6b5978656b4777524f655947326e6a56694169417a6449472f4f2f4a4f57466e566c50727569567332734844724a676356496f70446a4d76360a64696f4e31773d3d0a2d2d2d2d2d454e44202d2d2d2d2d0a
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [msp/identity] newIdentity -> DEBU c29 Creating identity instance for ID &{Proveedor 0bf7d673709e14cef044e09025b8511a590e2c758697ae07f2eef5283757787d}
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func2 -> DEBU c2a 0xc42010d530 identity 0 does not satisfy principal: The identity is a member of a different MSP (expected Usuario, got Proveedor
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func2 -> DEBU c2b 0xc42010d530 principal evaluation fails
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func1 -> DEBU c2c 0xc42010d530 gate 1498735036032103426 evaluation fails
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func1 -> DEBU c2d 0xc42010d530 gate 1498735036032902403 evaluation starts
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func2 -> DEBU c2e 0xc42010d530 signed by 0 principal evaluation starts (used [false])
orderer0.tec.com | 2017-06-29 11:17:16.032 UTC [cauthdsl] func2 -> DEBU c2f 0xc42010d530 processing identity 0 with bytes of 0a0950726f766565646f7212f4052d2d2d2d2d424547494e202d2d2d2d2d0a4d49494345444343416265674177494241674952414c595177764d593852483533594d4a7970767977457777436759494b6f5a497a6a3045417749776254454c0a4d416b474131554542684d4356564d78457a415242674e5642416754436b4e6862476c6d62334a7561574578466a415542674e564241635444564e68626942470a636d467559326c7a59323878466a415542674e5642416f544458427962335a6c5a5752766369356a623230784754415842674e5642414d5445474e684c6e42790a62335a6c5a5752766369356a623230774868634e4d5463774e6a49354d4467304d7a41335768634e4d6a63774e6a49334d4467304d7a4133576a42594d5173770a435159445651514745774a56557a45544d4245474131554543424d4b5132467361575a76636d3570595445574d4251474131554542784d4e5532467549455a790a5957356a61584e6a627a45634d426f474131554541784d546347566c636a417563484a76646d566c5a4739794c6d4e766254425a4d424d4742797147534d34390a4167454743437147534d34394177454841304941424b5137324e78684f744648354b62666876744e3068624a484f714d6c56734c37695262794e75626a5264630a785039784554507153313169492b33724b46336f4e622b7679777756555058376335653877616f2b6a46366a5454424c4d41344741315564447745422f7751450a417749486744414d42674e5648524d4241663845416a41414d437347413155644977516b4d434b4149496631483567312b535164576369307753386b536136370a45305a4d4651516944776f426a466978786d48434d416f4743437147534d343942414d43413063414d4551434945497a7451796f476e512f6d74334c685561640a3563585172415a6b5978656b4777524f655947326e6a56694169417a6449472f4f2f4a4f57466e566c50727569567332734844724a676356496f70446a4d76360a64696f4e31773d3d0a2d2d2d2d2d454e44202d2d2d2d2d0a
orderer0.tec.com | 2017-06-29 11:17:16.033 UTC [msp/identity] newIdentity -> DEBU c30 Creating identity instance for ID &{Proveedor 0bf7d673709e14cef044e09025b8511a590e2c758697ae07f2eef5283757787d}
orderer0.tec.com | 2017-06-29 11:17:16.033 UTC [msp] SatisfiesPrincipal -> DEBU c31 Checking if identity satisfies MEMBER role for Proveedor
orderer0.tec.com | 2017-06-29 11:17:16.033 UTC [msp] Validate -> DEBU c32 MSP Proveedor validating identity
orderer0.tec.com | 2017-06-29 11:17:16.033 UTC [cauthdsl] func2 -> DEBU c33 0xc42010d530 principal matched by identity 0
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [msp/identity] Verify -> DEBU c34 Verify: digest = 00000000 b0 ac 91 ca 2f e9 0d 5e 0d 48 d0 dc 11 06 3b 53 |..../..^.H....;S| orderer0.tec.com | 00000010 a1 d7 f9 d6 2f fe 7d fb 19 2c 90 cb 0f 67 4a 7e |..../.}..,...gJ~|
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [msp/identity] Verify -> DEBU c35 Verify: sig = 00000000 30 45 02 21 00 99 07 ef f1 72 66 96 f6 bc 5f cf |0E.!.....rf..._.| orderer0.tec.com | 00000010 ca a7 4c fd 86 de a2 5c 9e 87 02 ec 35 be df 8d |..L........5...| orderer0.tec.com | 00000020 65 3f 8a 48 67 02 20 38 6b 1d aa 86 f6 53 9c 76 |e?.Hg. 8k....S.v| orderer0.tec.com | 00000030 c1 10 f7 81 5d 1f 65 9a fd 92 fb 35 84 e1 71 ba |....].e....5..q.| orderer0.tec.com | 00000040 7f ce 14 54 d7 0a a7 |...T...|
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [cauthdsl] func2 -> DEBU c36 0xc42010d530 principal evaluation succeeds for identity 0
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [cauthdsl] func1 -> DEBU c37 0xc42010d530 gate 1498735036032902403 evaluation succeeds
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [orderer/common/sigfilter] Apply -> DEBU c38 Forwarding validly signed message for policy &{%!s(*common.ImplicitMetaPolicy=&{Readers 0}) %!s(int=1) [%!s(*policies.implicitMetaPolicy=&{0xc4201dcde0 1 [0xc42010d2a8 0xc42010d370 0xc42010d408]}) %!s(*policies.implicitMetaPolicy=&{0xc4201dc3a0 1 [0xc42010d228]})]}
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [orderer/common/deliver] Handle -> DEBU c39 [channel: canaltraza] Received seekInfo (0xc42081b260) start: > stop: >
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [fsblkstorage] retrieveBlockByNumber -> DEBU c3a retrieveBlockByNumber() - blockNum = [1]
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [fsblkstorage] newBlockfileStream -> DEBU c3b newBlockfileStream(): filePath=[/var/hyperledger/production/orderer/chains/canaltraza/blockfile_000000], startOffset=[14553]
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [fsblkstorage] nextBlockBytesAndPlacementInfo -> DEBU c3c Remaining bytes=[16306], Going to peek [8] bytes
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [fsblkstorage] nextBlockBytesAndPlacementInfo -> DEBU c3d Returning blockbytes - length=[16304], placementInfo={fileNum=[0], startOffset=[14553], bytesOffset=[14555]}
orderer0.tec.com | 2017-06-29 11:17:16.034 UTC [orderer/common/deliver] Handle -> DEBU c3e [channel: canaltraza] Delivering block for (0xc42081b260)
peer0.proveedor.com | 2017-06-29 11:17:16.031 UTC [deliveryClient] RequestBlocks -> DEBU 2d9 Starting deliver with block [1] for channel canaltraza
peer0.proveedor.com | 2017-06-29 11:17:16.038 UTC [blocksProvider] DeliverBlocks -> DEBU 2da [canaltraza] Adding payload locally, buffer seqNum = [1], peers number [0] peer0.proveedor.com | 2017-06-29 11:17:16.038 UTC [blocksProvider] DeliverBlocks -> DEBU 2db [canaltraza] Gossiping block [1], peers number [0]
peer0.proveedor.com | 2017-06-29 11:17:16.038 UTC [committer] Commit -> DEBU 2dc Validating block
。是的,可以使用Order By子句对日期进行排序。
答案 1 :(得分:1)
One值重新定位是由于查询结束时Limit 1
。
试试这个
db.rawQuery("select * from pd_data where item_type=1 and item_date like '%" + month + "%' order by item_date DESC ", null);