Hi,
dfernandez wrote:I am trying with this:
var q = 'SELECT customer, COUNT(document) as TotalInvoices, SUM(subtotal) AS TotalSales FROM Docs GROUP BY customer';
var uuri = databaseManager.createDataSourceByQuery('SalesByCustomer', 'mem', q, null, 999);
The syntax for the createDataSourceByQuery is
- Code: Select all
databaseManager.createDataSourceByQuery(name:String, server_name:String, sql_query:String, arguments:Object[], max_returned_rows:Number)
So if 'mem' is your In-Memory datasource name and 'SalesByCustomer' your connection name then you have switched them around.
So it should look like this:
- Code: Select all
var q = 'SELECT customer, COUNT(document) as TotalInvoices, SUM(subtotal) AS TotalSales FROM Docs GROUP BY customer';
var uuri = databaseManager.createDataSourceByQuery('mem', 'SalesByCustomer', q, null, 999);
Also I see your table name has caps in them. If they are indeed defined with caps in your database (normally it defaults to all lower- or all uppercase, depending on your db vendor) then you need to quote these database objects with double quotes in your SQL ( i.e."TotalSales").
Hope this helps.