oracle - Counting the total number of rows depending on a column value -


i have query should count total number of rows returned depending on column value. example:

enter image description here

as can see, m field should display total number of rows returned should 5 because ft_lot same value. here query have far:

select distinct vbatch_id, maxim_pn, bagnumber, ft_lot , m  , level n ( select vbatch_id, maxim_pn, bagnumber, ft_lot, qty, dc, printdate, ws_green, ws_pnr, ws_pcn, msl, baketime, exptime , una , dulo , (dulo - una) + 1 m  ( select c.containername vbatch_id ,pb.productname maxim_pn ,bn.wipdatavalue bagnumber ,ln.wipdatavalue ft_lot  ,aw.wipdatavalue qty ,decode(ln.wipdatavalue,la.attr_081,la.attr_083 ,la.attr_085,la.attr_087 ,la.attr_089,la.attr_091 ,la.attr_093,la.attr_095 ,la.attr_097,la.attr_099 ,la.attr_101,la.attr_103 ,la.attr_105,la.attr_107 ,la.attr_109,la.attr_111 ,la.attr_113,la.attr_116 ,la.attr_117,la.attr_119  ) dc  ,to_char(sysdate,'mm/dd/yyyy hh:mi:ss pm') printdate  ,decode(upper(la.attr_158),'green','hf',null) ws_green  ,decode(la.attr_140,null,null,'pnr') ws_pnr  ,decode(la.attr_080,null,null,'pcn') ws_pcn  ,p.attr_011 msl ,p.attr_013 baketime ,p.attr_014 exptime , case when instr(bn.wipdatavalue, '-') = 0 bn.wipdatavalue else substr(bn.wipdatavalue, 1, instr(bn.wipdatavalue, '-')-1)  end una , case when instr(bn.wipdatavalue, '-') = 0 bn.wipdatavalue else substr(bn.wipdatavalue, instr(bn.wipdatavalue, '-') + 1) end dulo container c join a_lotattributes la on c.lotattributesid = la.lotattributesid join product p on c.productid=p.productid join productbase pb on p.productbaseid=pb.productbaseid join a_adhocwipdatarecord on a.objectrefid=c.containerid join a_adhocwipdatarecorddetails bn on a.adhocwipdatarecordid=bn.adhocwipdatarecordid , bn.wipdatanamename ='tr_bag_number' left join a_adhocwipdatarecorddetails ln on a.adhocwipdatarecordid=ln.adhocwipdatarecordid , ln.wipdatanamename ='tr_ft_lot number' left join a_adhocwipdatarecorddetails aw on a.adhocwipdatarecordid=aw.adhocwipdatarecordid , aw.wipdatanamename ='tr_ft lot qty' ln.wipdatavalue = :ftlot , bn.wipdatavalue :wip ) ) level :n connect level <= m order bagnumber 

thanks helping out guys.

actually group not solution. having looked again @ desired output have realised want analytic count.

your posted query bit of mess and, sorry ,but i'm not prepared invest time in it. sort of structure need:

 select vbatch_id, maxim_pn, bagnumber, ft_lot         , count(*) on (partition ft_lot) m  whatever ...  

find out more.

not sure why need distinct. distinct indicates failure clause right.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -