Hi all,

I am doing a porting of application from Postgres to SAP DB. 
I found out the following problem for that I had not found a solution (search through 
mailing list did not give me the answer)

The model of the queri is the following (the really simplified original query that has 
the same problem):

Lets say we have a table:

create table ttt(id int, v int, c int)

and the following SQL query: 

select f.id, sum(f.vvv) from 
(select id, 1 as vvv from ttt where c = 1 union select id, 0 as vvv from ttt where c 
=2 union  select id, 3 as vvv from ttt where c = 3) f group by f.id 
union 
select f.id, sum(f.vvv) from 
(select id, 1 as vvv from ttt where c = 1 union select id, 0 as vvv from ttt where c 
=2 union  select id, 3 as vvv from ttt where c = 3) f group by f.id

This query runs fine with PostgresSQL however SAP DB (7.3) responds with " ID must be 
a group column".

Moreove if I take a part of this query (doesn't matter which one) and execute 

"select f.id, sum(f.vvv) from 
(select id, 1 as vvv from ttt where c = 1 union select id, 0 as vvv from ttt where c 
=2 union  select id, 3 as vvv from ttt where c = 3) f group by f.id"
it works fine.  

Using the number of column instead of its name does not work work group by clause.

Is there any solution of this problem since the PSQL's behaviour seems to be right in 
this case?

Thanks in advance,
Dmitri
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to