Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Put Max (ID) in a Group by query

3273628Jul 11 2016 — edited Jul 11 2016

I need help with a Query,

I want to put the maximum value of id in the grouped table and show that id in result

I have this:

SELECT SUM(T1.quantity1),SUM(T1.quantity2),T1.RESOURCEID,T1.DOCUMENTCOSTDATE,

from TB_REPORTCOSTS T1, TB_EMPLOYEE

where T1.DOCUMENTNUMBER='123VGH123'

and  T1.RESOURCEID=TB_EMPLOYEE.ID

GROUP BY T1.RESOURCEID, T1.DOCUMENTCOSTDATE

Grouped by employee and date but I need the row identifier

I Want this

SUM1SUM2ResourceIDDOCDateID
3123101/01/20162
4332101/02/20163
2453201/01/20165
23432301/02/20166

From this:

quantity1quantity2ResourceIDDOCDateID
1100101/01/20161
223101/01/20162
4332101/02/20163
1253201/01/20164
120201/01/20165
23432301/01/20166

Thanks you for your time!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2016
Added on Jul 11 2016
1 comment
672 views