ある種の入札方法を含むすべてのカード取引について報告しようとしています。XMLSEQUENCE - 子が "void"を含む場合、親を無視する
「登録番号」、「トランザクション数」、「合計値」という3つの列のレポート。
私が持っている問題は、トランザクションに複数の "TokenisedCardTenderItem"が含まれている可能性があります。以下のクエリでは、これらとカウントと合計が正しく取得されます。しかしながら...
"TokenisedCardTenderItem"は、特定の入札が取り消された何らかの理由で、 "VoidValue"という意味の子供を含むことができます。以下のクエリでは、これらの値を数え加えています。
私の質問は、 "VoidValue"という子を持つが、そうでない "TokenisedCardTenderItem"を数え続けているすべての "TokenisedCardTenderItem"を除外する方法です。私が見て望んでいるだろう。このことから
<POSBasket>
<TokenisedCardTenderItem>
<LineNumber>3</LineNumber>
<NetValue>-1</NetValue>
<VoidValue>1</VoidValue>
<EffectiveNetValue>-1</EffectiveNetValue>
</TokenisedCardTenderItem>
<VoidItem>
<LineNumber>4</LineNumber>
<NetValue>1</NetValue>
<EffectiveNetValue>1</EffectiveNetValue>
<VoidedLineNumber>3</VoidedLineNumber>
</VoidItem>
<TokenisedCardTenderItem>
<LineNumber>5</LineNumber>
<NetValue>2</NetValue>
<EffectiveNetValue>2</EffectiveNetValue>
<PreformattedTextLines>
<PreformattedTextVoucherType>1</PreformattedTextVoucherType>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine>CONTACTLESS</PreformattedTextLine>
<PreformattedTextLine>SALE</PreformattedTextLine>
<PreformattedTextLine>TOTAL: GBP0.02</PreformattedTextLine>
</PreformattedTextLines>
</TokenisedCardTenderItem>
<TokenisedCardTenderItem>
<LineNumber>6</LineNumber>
<NetValue>3</NetValue>
<EffectiveNetValue>3</EffectiveNetValue>
<PreformattedTextLines>
<PreformattedTextVoucherType>1</PreformattedTextVoucherType>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine></PreformattedTextLine>
<PreformattedTextLine>CONTACTLESS</PreformattedTextLine>
<PreformattedTextLine>SALE</PreformattedTextLine>
<PreformattedTextLine>TOTAL: GBP0.03</PreformattedTextLine>
</PreformattedTextLines>
</TokenisedCardTenderItem>
</POSBasket>
:
SELECT
terminal_number
,count (Extractvalue(c.column_value, 'TokenisedCardTenderItem/PreformattedTextLines/PreformattedTextLine[7]')) as con
,count (Extractvalue(c.column_value, 'TokenisedCardTenderItem/NetValue'))/100 as val
FROM baskets b ,
TABLE(xmlsequence(extract(xmltype(b.xml),'/POSBasket/TokenisedCardTenderItem'))) c
where DATE_CREATED>TO_DATE('2017-05-12 00:00:00','yyyy-MM-dd HH24:mi:ss')
AND store_id = 9999
AND terminal_number = 982
and EXISTSNODE(xmltype.createxml(xml), '/POSBasket/TokenisedCardTenderItem/PreformattedTextLines[PreformattedTextLine="CONTACTLESS"]') = 1
GROUP BY terminal_number,
Extractvalue(c.column_value, 'PreformattedTextLines/PreformattedTextLine[7]')
order by 1,2
は、以下のXMLのバージョンをダウンカット
Terminal Con Val
982 2 0.05
しかし、ボイドnetvalueが含まれているように私は以下を得ます。
Terminal Con Val
982 2 0.06
探しているものだと思います。 – MT0