You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently, using JSON table data, and aggregating the entire table into one record (no GROUP BY):
the SUM function works fine, but
the MAX/MIN functions return "undefined"
and the GREATEST/LEAST functions return 0.
The implementation does not let minand max handle other values than numbers
sql = "SELECT max(text) as text FROM ?"
data = [{"text":"2","value":"ConfigPanel"},{"text":"5","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{"text":5}]
sql = "SELECT max(text) as text FROM ?"
data = [{"text":"abc","value":"ConfigPanel"},{"text":"def","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{}]
Im not sure how other databases handles minand max - but we will have to look into it.
I recommend you order and limit to one to get the same result with text
sql = "SELECT text as text FROM ? ORDER BY text DESC LIMIT 1"
data = [{"text":"abc","value":"ConfigPanel"},{"text":"def","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{"text":"def"}]
Ah, that's the issue. I am also an ms sql server guy, so i didn't know
about the limit command. I'm used to select top. I will try your
solution. Thank you.
The implementation does not let minand max handle other values than
numbers
sql = "SELECT max(text) as text FROM ?"
data = [{"text":"2","value":"ConfigPanel"},{"text":"5","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{"text":5}]
sql = "SELECT max(text) as text FROM ?"
data = [{"text":"abc","value":"ConfigPanel"},{"text":"def","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{}]
Im not sure how other databases handles minand max - but we will have to
look into it.
I recommend you order and limit to one to get the same result with text
sql = "SELECT text as text FROM ? ORDER BY text DESC LIMIT 1"
data = [{"text":"abc","value":"ConfigPanel"},{"text":"def","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{"text":"def"}]
—
Reply to this email directly or view it on GitHub #411 (comment).
Good to know you could use the answer... AlaSQL also supports the MSSQL notation:
sql = "SELECT TOP 1 text FROM ? ORDER BY text DESC"
data = [{"text":"abc","value":"ConfigPanel"},{"text":"def","value":"ConfigPanelEdit"}]
console.log(JSON.stringify(alasql(sql, [data])))
// [{"text":"def"}]
Activity
trittberg commentedon Sep 12, 2015
Sorry, by data example was wrong ... more like
Sorry,
Timm
mathiasrw commentedon Sep 14, 2015
Hey @trittberg - please provide your SQL so we can help you debug...
trittberg commentedon Sep 16, 2015
Hi Mathias
Here is my dilemma.
SQL: "SELECT MAX(text) AS text FROM ?"
DATA: [{"text":"ConfigPanel","value":"ConfigPanel"},{"text":"ConfigPanelEdit","value":"ConfigPanelEdit"},
... ]
RESULT: alasql(SQL, [data])[0].text = undefined
Please see the attachment for SQL, data and result details.
Thanks,
Timm
On 14 September 2015 at 02:47, Mathias Rangel Wulff <
notifications@github.com> wrote:
Cheers,
Timm
mathiasrw commentedon Sep 17, 2015
The implementation does not let
minandmaxhandle other values than numbersIm not sure how other databases handles
minandmax- but we will have to look into it.I recommend you order and limit to one to get the same result with text
[-]MAX/MIN function not working for JSON data[/-][+]MAX/MIN function not working for words[/+]trittberg commentedon Sep 17, 2015
Ah, that's the issue. I am also an ms sql server guy, so i didn't know
about the limit command. I'm used to select top. I will try your
solution. Thank you.
Timm
On Thu, Sep 17, 2015, 7:12 AM Mathias Rangel Wulff notifications@github.com
wrote:
mathiasrw commentedon Sep 18, 2015
Good to know you could use the answer... AlaSQL also supports the MSSQL notation:
rahulraj-120799 commentedon Aug 12, 2021
MONTHNAME(), GETDATE is not working in alasql