Reputation: 15379
Normally, if I want to concatenate two strings and apply an aggregate I follow this syntax:
Sql Server
SELECT substring(t.field, 1, 3) + substring(t.field, 5,7), count(*)
FROM myTable t
GROUP BY substring(t.field, 1, 3) + substring(t.field, 5,7)
Oracle
SELECT CONCAT(substring(t.field, 1, 3), substring(t.field, 5,7)), count(*)
FROM myTable t
GROUP BY CONCAT(substring(t.field, 1, 3), substring(t.field, 5,7))
In OrientDB, is it possible concatenate two strings and get an aggregate of them?
Upvotes: 1
Views: 1526
Reputation: 255
Try this, the parser and the query executor of OrientDb can be some time a litle choosy expecially with the group by option, this would work with the 'Strict mode' disabled (studio -> log in -> db -> second tab on the bottom)
SELECT id, $goofy , count(*) as cont from myTable
LET $sub = id.subString(4),
$goofy = id.subString(1,3).append($sub)
group by $goofy
note: i've splitted the code in 2 variable couse the parser have some problem parsing the function inside the .append I'm pretty sure that in the next releases of Orientdb this kind of issue will be fixed (they alredy have a new parser in development)
Upvotes: 2