Grid Custom SQL

I have created a Grid application with my own SQL statement to group and sum totals:
SELECT
cl.clName,
sum(mi.mntTotalCharge) as total,
mi.mntMonth,
mi.mntYear
FROM
Clients cl INNER JOIN Agreements agr ON cl.cID = agr.cID
INNER JOIN MonthlyInvoices mi ON agr.agrID = mi.agrID
where mi.mntMonth = Month(now()) and mi.mntYear =year(now())
Group by cl.clName,mi.mntYear,mi.mntMonth
order by total DESC
limit 10

Scriptcase “ignores” this statement and groups the first 10 clients in the table and shows them alphabetically.

What am I missing when executing custom SQL ?

Hello, I hope i have understood correctly your post.

I have had a similar issue before, what I do is when you create the grid to put in your own sql then not later.

  1. Create new Application Grid
  2. Select connection in a grid
  3. Select the table
  4. The sql will be created for you at this stage remove this and paste your own sql in there and the create. should work.

Thanks for the reply Paul. I tried your suggestion but the result remains the same. I will experiment and let you know.