3

I am trying to run a query like :

query temp{
  description: "Find bidder with highest balance"
  statement:
        SELECT org.dltlabs.auctionModel.Bidder
        WHERE (balance > _$balance)
        ORDER BY balance
}

I am running a query on Hyperledger composer playground. It gives me an error saying :

Error: Cannot sort on field(s) "balance" when using the default index

How can we sort in the Playground using query or order by?

  • Hi Leena, did you solve it ? – Moro Aug 19 '18 at 12:25
  • @Moro Didn't got any solution for that error, but able to sort data by directly hitting to CouchDB as M using CouchDB. CouchDB don't allow to sort fields other than **id**. Workaround for that is to create index or to use view. – Leena Bharambe Sep 05 '18 at 08:06

1 Answers1

0

What would be the data type of the "balance" field? Some SQL Server data types (text, ntext, and image) can not be sorted. If this is the case, just change the last two lines to the following:     

WHERE (CAST(balance AS VARCHAR(MAX)) > _$balance)
ORDER BY CAST(balance AS VARCHAR(MAX))
Silvair L. Soares
  • 1,018
  • 12
  • 28