cancel
Showing results for 
Search instead for 
Did you mean: 

HANA SQL - Multiple Aggregations in SELECT

BenedictV
Active Contributor
0 Kudos

Hi,

I want to know if we can pass multiple aggregation functions values to variables in a single SELECT statement.

Here's a sample code on a test table, similar to the actual code that fails with the same error,

insert into <table> values(11,'lox'); 

insert into <table> values(12,'pox'); 
insert into <table> values(13,'sox'); DO (OUT mini INT => ?, OUT maxi INT => ?) BEGIN Select MIN("id") into mini, MAX("id") into maxi from "PUBLIC"."HEADERTAB"; END Error: Could not execute 'DO (OUT mini INT => ?, OUT maxi INT => ?) BEGIN Select MIN("id") into mini, MAX("id") into maxi ...' in 3 ms 688 µs . SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "(": line 3 col 30 (at pos 81) But the below statement works: Select MIN("id") as "mini", MAX("id") as "maxi" from "PUBLIC"."HEADERTAB"

I am doing this in a procedure and trying to pass the minimum and maximum values into a variable. Right now I am doing at two separate SELECTs.

Thank You,

Benedict

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor

You have to use just one "into" clause.

SELECT min("id"), max("id") INTO mini, maxi from "PUBLIC"."HEADERTAB";

Answers (0)