Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
magnusrydberg
Partner - Contributor II
Partner - Contributor II

Error when using SUM and GROUP BY in sqript

I am running this sqript using SUM and GROUP BY function in a load statement:

LOAD

    StringKey1 as ContLONumber,

    StringKey4 as ContSequence,

    Status as ContStatus,

    Sum("Time") as ContLogTime

    Group By StringKey1;

    SQL SELECT * FROM "MyL_PROD_220".OTSDATA.TimeLog where StringKey6='CONT';

When executing the sqript I'll got the error message "invalid expression"

What is not correct in my sqript?

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

If you use a Group By, ALL the non-aggregated fields must be in the Group By list. So this should work

LOAD

    StringKey1 as ContLONumber,

    StringKey4 as ContSequence,

    Status as ContStatus,

    Sum("Time") as ContLogTime

    Group By StringKey1, StringKey4, Status;

SQL SELECT * FROM "MyL_PROD_220".OTSDATA.TimeLog where StringKey6='CONT';

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

If you use a Group By, ALL the non-aggregated fields must be in the Group By list. So this should work

LOAD

    StringKey1 as ContLONumber,

    StringKey4 as ContSequence,

    Status as ContStatus,

    Sum("Time") as ContLogTime

    Group By StringKey1, StringKey4, Status;

SQL SELECT * FROM "MyL_PROD_220".OTSDATA.TimeLog where StringKey6='CONT';

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
magnusrydberg
Partner - Contributor II
Partner - Contributor II
Author

Thanks a lot Jonathan! Now it works and I understand the "Group By" statement