0

I have a dynamic SOQL query where in I am using order by clause.I want to sort it by product Style

SOQL

soql = 
'select id, name,Warehouse__c,Product_Reference__r.gii__ProductStyle__r.name, 
Product_Inventory__c , Product_Reference__c,Product_Inventory__r.gii__Product__r.name,
Product_Inventory__r.gii__Product__r.gii__ProductStyle__r.name,Product_Reference__r.gii__ProductCode__c, 
Sales_Year__c,(select id,name,Quantity__c,Month__c from Forecast_Details__R)'+
' from forecast__c where Sales_Year__c =' + '\''+selectSalesYear.id +'\''+ 'and Warehouse__c =\'' + selectedWarehouse.id + '\' ' + 
filterQueryPart  + 
                ' Order By Product_Reference__r.gii__ProductStyle__r.name NULLS Last, 
Product_Inventory__r.gii__Product__r.name NULLS Last limit ' + PageSize + ' offset ' + PageNumber*PageSize;

If i am using NULLS First, its working like a charm. But in Nulls Last, it is not working, all the Product style which are null are coming first.

Can someone help me with the error??

Thanks

Samir

1 Answer 1

0

You are missing the NULLS LAST for one of the column Product_Inventory__r.gii__Product__r.gii__ProductStyle__r.name

Try this at the end of your string:

' Order By Product_Reference__r.gii__ProductStyle__r.name NULLS Last,'+
' Product_Inventory__r.gii__Product__r.name NULLS Last limit ' +
' Product_Inventory__r.gii__Product__r.gii__ProductStyle__r.name NULLS LAST '+
 PageSize + ' offset ' + PageNumber*PageSize
2
  • Sorry ..that is not a problem..Query Is correct.I was storing this data in a list and was sorting it using Sort() .When i commented the sort() ..it worked. Thanks for looking into this :).
    – Samir
    Commented Feb 23, 2016 at 12:39
  • 1
    Cool. Good that you figured it out yourself :) Commented Feb 23, 2016 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .