RECORD_TYPE ='ERROR'の場合、Record_Noによって各location_Nameの一意のレコード数を取得する方法。RECORD_NOに対してRECORD_TYPE='ERROR'のレコードが複数ある場合は、RECORD_NOに対して1つのレコードのみをカウントし、最後にこれらすべてのレコードをLOCATION_NAMEでグループ化する必要があります。これはxmlの日付です。
<root>
<SellOutErrorRecord>
<RECORD_TYPE>WARNING</RECORD_TYPE>
<RECORD_NO>1</RECORD_NO>
<ERROR_DESC>trx doc type is invalid</ERROR_DESC>
<LOCATION_NAME>Chen Ken</LOCATION_NAME>
<PRODUCT_NUMBER>336549R-001</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<RECORD_NO>2</RECORD_NO>
<ERROR_DESC>invoice amount is zero</ERROR_DESC>
<LOCATION_NAME>Chen Ken</LOCATION_NAME>
<PRODUCT_NUMBER>3X-KN73C-DB</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>sales qty is zero</ERROR_DESC>
<RECORD_NO>2</RECORD_NO>
<LOCATION_NAMEChen Ken</LOCATION_NAME>
<PRODUCT_NUMBER>3X-KN73C-DB</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>trx currency is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>Chen Ken</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>invoiced net amount is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>Chen Ken</LOCATION_NAME>
<PRODUCT_NUMBER>445860-B21</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>invoiced net amount is invalid</ERROR_DESC>
<RECORD_NO>1</RECORD_NO>
<LOCATION_NAME>Chen Ken</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>WARNING</RECORD_TYPE>
<RECORD_NO>1</RECORD_NO>
<ERROR_DESC>trx doc type is invalid</ERROR_DESC>
<LOCATION_NAME>Cheng Boon</LOCATION_NAME>
<PRODUCT_NUMBER>336549R-001</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<RECORD_NO>2</RECORD_NO>
<ERROR_DESC>invoice amount is zero</ERROR_DESC>
<LOCATION_NAME>Cheng Boon</LOCATION_NAME>
<PRODUCT_NUMBER>3X-KN73C-DB</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>*-
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>sales qty is zero</ERROR_DESC>
<RECORD_NO>2</RECORD_NO>
<LOCATION_NAME>Cheng Boon</LOCATION_NAME>
<PRODUCT_NUMBER>3X-KN73C-DB</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>trx currency is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>Cheng Boon</LOCATION_NAME>
<PRODUCT_NUMBER>339112-B25</PRODUCT_NUMBER>
</SellOutErrorRecord>
<SellOutErrorRecord>
<RECORD_TYPE>ERROR</RECORD_TYPE>
<ERROR_DESC>invoiced net amount is invalid</ERROR_DESC>
<RECORD_NO>3</RECORD_NO>
<LOCATION_NAME>Cheng Boon</LOCATION_NAME>
<PRODUCT_NUMBER>445860-B21</PRODUCT_NUMBER>
</SellOutErrorRecord>
</root>
期待される出力は次のとおりです。
LOCATION_NAME:Chen Ken COUNT:3
LOCATION_NAME:Cheng Boon COUNT:2