buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
force-app/main/default/classes/LexConsumableAccountSOQL.cls
@@ -1,13 +1,14 @@
public with sharing class LexConsumableAccountSOQL {
    public static AggregateResult[] getAccountBySales(Datetime thisDatetime ,Datetime nextDatetime){
        AggregateResult[] arList = new List<AggregateResult>([
            SELECT count(id), Consumable_order__r.Order_ForHospital__r.name hospitalName, sum(Sale_amount__c) thisAmount
            SELECT Consumable_order__r.Order_ForHospital__c,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 != ''
            GROUP BY Consumable_order__r.Order_ForHospital__r.Name
            GROUP BY Consumable_order__r.Order_ForHospital__c,Consumable_order__r.Order_ForHospital__r.name
            ORDER BY sum(Sale_amount__c) DESC
            LIMIT 10
        ]);
@@ -18,7 +19,9 @@
        AggregateResult[] saleAmountList = [
            SELECT sum(Sale_amount__c) saleAmount
            FROM Consumable_Orderdetails__c
            WHERE CreatedDate >= :thisDatetime AND CreatedDate < :nextDatetime
            WHERE CreatedDate >= :thisDatetime
            AND CreatedDate < :nextDatetime
            AND Consumable_order__r.Order_ForHospital__r.name != ''
        ];
        return saleAmountList;
    }