MAX() in ORACLE SQL -


i have table stores list of records maintenance tasks have been done , date , time done. i'm trying sub-query pull out records each task has recent date. sql statement is:

    select "engineering_compliance"."eo" "eo",        "engineering_compliance"."ac" "ac",        "engineering_compliance"."pn" "pn",        "engineering_compliance"."pn_sn" "pn_sn",        "engineering_compliance"."hours_reset" "hours_reset",        "engineering_compliance"."minutes_reset" "minutes_reset",        "engineering_compliance"."cycles_reset" "cycles_reset",        "engineering_compliance"."reset_date" "reset_date",        "engineering_compliance"."reset_hour" "reset_hour",        "engineering_compliance"."reset_minute" "reset_minute",        max ( "engineering_compliance"."reset_date" ) "last_comp_date"   engineering_compliance group ( "engineering_compliance"."eo" ) ,        ( "engineering_compliance"."ac" ) ,        ( "engineering_compliance"."pn" ) ,        ( "engineering_compliance"."pn_sn" ) 

however keep getting following error: "ora-00979: not group expression"

when remove "group by" get: "ora-00937: not single-group group function"

1 - mean 2 - wrong statement?

the columns ever added in select clause without aggregate function should in group clause.

to make little bit clear:
take example:

you have transactionid, accountid, transactionamount, transactiondate in select clause, , need sum(transactionamount) on dates, in case, if add

select transactiondate, transactionid, accountid, sum(transactionamount)  table  group transactiondate 

then error, why because
assume have 4 transactions on 20160101 , each transactionamount $1000
result expectation be

transdate      transamt  20140101          4000 

in case, if bring other attributes in select clause accountid , transactionid, go? why have include attributes in group clause ever in select clause except 1 aggregate function.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -