お世話になります。
集計のサーチ文の書き方についてご教示ください。
やりたいことは下記の通りです。
・販売数で集計し、Top3を出力する。
・その他は合計して集計する。
・販売数で集計した結果に、商品名をキーとして割引販売数の集計値をマージする。
出力イメージは以下の通りです。
商品名 | 販売数 |
aaa | 300 |
aaa | 400 |
aaa | 500 |
bbb | 300 |
ccc | 200 |
ccc | 300 |
ccc | 500 |
ddd | 100 |
ddd | 100 |
eee | 800 |
商品名 | 割引販売数 |
aaa | 100 |
aaa | 50 |
aaa | 200 |
bbb | 200 |
ccc | 10 |
ccc | 200 |
ccc | 100 |
ddd | 20 |
ddd | 50 |
eee | 100 |
集計後イメージ
商品名 | 販売数 | 割引販売数 |
aaa | 1200 | 350 |
ccc | 1000 | 310 |
eee | 800 | 100 |
その他 | 500 | 270 |
宜しくお願い致します。
index=yourindex
| stats sum("Number of sales") as sum_Number_of_sales by "Product name"
| append [search index=yourindex
| stats sum("Discount sales") as sum_Discount_sales by "Product name"]
| stats values(*) as * by "Product name"
| sort - sum_Number_of_sales
Thank you for your comment.
I tried it, but I couldn't aggregate other total values.
Let's consider a little more with reference to the SPL you received.