• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i write a criteria to sum of values in the subquery

 
Asvin Kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im new to hibernate, how can I do a sum of subquery values?

SELECT SUM(Salary) as sal from (

SELECT salary
FROM SAL
WHERE EMPLOYEE_NUM = ?
AND CUR_MONTH = CONCAT( TO_CHAR( SYSDATE, 'MON'), TO_CHAR(SYSDATE,'YYYY'))
AND CONTRACT_END_DATE < LAST_DAY(SYSDATE)

)

Any input would be helpful.

Thanks,
Asvin
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using a subquery? Why not simply execute
 
Asvin Kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I did that. Actually I wanted to ask for this scenario but I pasted the wrong query,


I tried this,



But it is not working.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic