NetSuite管理者は、各顧客の最大請求書を迅速に識別する必要がある場合があります。これは、価値の高いトランザクションのレビュー、回収分析のサポート、顧客レポートの準備または請求書活動の検証に役立ちます。
この記事では、SuiteQLを使用して、各顧客の請求書金額別に顧客請求書をランク付けします。各顧客について最も高い金額の請求書はランク1を受け取ります。
SuiteQL問合せの例
次のサンプルは顧客請求書を返し、請求書金額に基づいてランクを割り当てます。各顧客のランキングが再開されます。
SELECT
t.entity AS customer_id, -- Customer internal ID
BUILTIN.DF(t.entity) AS customer_name, -- Customer display name
t.tranid AS invoice_number, -- Invoice number
t.trandate AS invoice_date, -- Invoice date
t.foreignTotal AS invoice_total, -- Invoice amount used for ranking
RANK() OVER (
PARTITION BY t.entity -- Restart ranking for each customer
ORDER BY t.foreignTotal DESC -- Highest invoice amount gets rank 1
) AS invoice_rank -- Rank result
FROM
Transaction t
WHERE
t.type = 'CustInvc' -- Show customer invoices only
ORDER BY
t.entity,
invoice_rank,
t.trandate DESC