Hello.
I’m trying to sum a column by a table in db sql and put the result into a variable, but my code doesn’t work. Can anyone solve and tell me where is my syntax error?
function sum () local xyz = 0 local sums = "SELECT SUM (import) as = '".. xyz .."' FROM Tables '" db:exec( sums ) print (xyz) end
This should do the trick.
[lua]
local function sum()
local xyz = 0
local sums = [[Select sum(import) as total from tables]]
for row in db:nrows(sums) do
xyz = row.total
end
print (xyz)
end
[/lua]
This should do the trick.
[lua]
local function sum()
local xyz = 0
local sums = [[Select sum(import) as total from tables]]
for row in db:nrows(sums) do
xyz = row.total
end
print (xyz)
end
[/lua]