• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

aggregate function using alias name and fetch the result into the resultset using the Alias name

 
mogana kumar
Greenhorn
Posts: 2
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to perform calculation using aggregate function by specifying the alias name inside that function and retrieve the data into my resultset using the alias name given for that aggregate function... when I tried to do that I got an Exception saying "Invalid Identifier" how to resolve this?


my Query:

select customername,

to_char(dt,'ddmonyy'),

lpad(sum(mtot),15) as AliasName

from (

select customername,

dt,

sum(traffic) as mtot

from table

where dt >= trunc (SYSDATE -1)

group by customername,

dt,

0,

0,

0

)
group by customername,

to_char(dt,'ddmonyy'),

AliasName having customername = 'BB'




I got an error "Invalid Identifier" when I try to fetch the data using the following java code:

rs.getInt("AliasName");
 
Paul Clapham
Sheriff
Posts: 21548
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That could be because "table" is a reserved word in your SQL dialect. Try calling your table something more meaningful than "table".
 
mogana kumar
Greenhorn
Posts: 2
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I have specified the table name as "table" but in my java code I have specified table name as "CUSDETAILS"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic