binxie
2023-06-26 b5c5eb130ca0848124f9d136af4be142ad5aac07
force-app/main/default/classes/LexConsumableAccountSOQL.cls
@@ -1,15 +1,16 @@
public with sharing class LexConsumableAccountSOQL {
    public static AggregateResult[] getAccountBySales(Datetime thisDatetime, Datetime nextDatetime) {
        AggregateResult[] arList = new List<AggregateResult>(
            [
        AggregateResult[] arList = new List<AggregateResult>([
                SELECT count(id), Consumable_order__r.Order_ForHospital__r.name hospitalName, sum(Sale_amount__c) thisAmount
                FROM Consumable_Orderdetails__c
                WHERE CreatedDate >= :thisDatetime AND CreatedDate < :nextDatetime AND Consumable_order__r.Order_ForHospital__r.name != ''
            WHERE
                CreatedDate >= :thisDatetime
                AND CreatedDate < :nextDatetime
                AND Consumable_order__r.Order_ForHospital__r.name != ''
                GROUP BY Consumable_order__r.Order_ForHospital__r.Name
                ORDER BY sum(Sale_amount__c) DESC
                LIMIT 10
            ]
        );
        ]);
        return arList;
    }
@@ -21,4 +22,6 @@
        ];
        return saleAmountList;
    }
}