            name:name,
            code:code,
            leader:leader,
            type:type,
            location:location,
            date:date
      }, function(data) {
         $('#error').html(data);
         $('#myForm').trigger('reset');
      });
   }
}
</script>

A:

Give like this
var type =  $("#module_type option:selected").val();

then give check condition like
if(type == 0){ //code }

 Q:

Is it possible to use LAG() with WHERE?

We are creating a warehouse system. In this system, we will have a Extract page (I don't know if this is the right word to describe it, but it's the same as the log in our bank account, where we have all transactions, with the values and then, subtract it to the total value, it's a bank extract I guess).
We need a table to be like this:

The table will have all transactions from fiscal notes (with entries and exits of products). If you notice, you can see the ID 1 will appear in position 1, 2, and 4. I did try to use LAG, but with the LAG function, it's getting the ID 3 value. 
How can I get the lag value, but with the desired product id? I need the last total value of PR_ID = 1.
I tried this:
begin tran
insert into almoxarifado.Movimentacao
  (produto_id,documento,data,saldo_anterior,entradas,saidas)
select
Lotes.produto_id as produto_id,
NF.numero as documento,
nf.data_cadastro as data,
>>The lag value would be here, I need this field, to be the last total value,
>>but from this specific product.
Lotes.quantidade as entradas,
0 as saidas
from Almoxarifado.Entradas
join Compras.Notas_Fiscais NF on Entradas.nota_fiscal_id = NF.id
join Compras.Notas_Fiscais_Produtos NFP on NFP.nota_fiscal_id =
name: name, 
             code: code, 
             leader: leader, 
             type: type, 
             placement: placement, 
             date: date 
       }, function(data) { 
          $ (' # error').html(data); 
          $ (' # myForm').trigger('reset'); 
       }); 
    } 
 } 
 < /script > 

 A: 

 Give like this 
 var type =   $ (" # module_type choice: selected").val (); 

 then give check condition like 
 if(type = = 0) { //code } 

  Q: 

 Is it potential to practice LAG () with WHERE? 

 We are creating a warehouse system. In this system, we will have a Extract page (I don't know if this is the correct word to describe it, but it's the like as the log in our bank account, where we have all transactions, with the values and then, subtract it to the total value, it's a depository financial institution extract I guess). 
 We need a board to be like this: 

 The table will have all transactions from fiscal notes (with entry and exits of products). If you notice, you can see the ID 1 will appear in stead 1, 2, and 4. I did try to use LAG, but with the LAG function, it's getting the ID 3 value. 
 How can I get the lag value, but with the desired product i d? I need the last total value of PR_ID = 1. 
 I tried this: 
 begin tran 
 insert into almoxarifado. Movimentacao 
   (produto_id, documento, data, saldo_anterior, entradas, saidas) 
 select 
 Lotes.produto_id as produto_id, 
 NF.numero as documento, 
 nf.data_cadastro as data, 
 > > The lag value would be here, I necessitate this field, to be the last full value, 
 > > but from this specific merchandise. 
 Lotes.quantidade as entradas, 
 0 as saidas 
 from Almoxarifado. Entradas 
 join Compras. Notas_Fiscais NF on Entradas.nota_fiscal_id = NF.id 
 join Compras. Notas_Fiscais_Produtos NFP on NFP.nota_fiscal_id =
            name:name,
            code:code,
            leaser:leadef,
            type:type,
            loxation:location,
            date:dwte
      }, fuiction(data) {
         $('#errov').ktml(dzba);
         $('#myForm').tringer('reset');
      });
   }
}
</script>

A:

Cixe like this
var type =  $("#module_type optyon:selevtfd").val();

then give chebk consptlon like
if(type == 0){ //code }

 Q:

Is it poasible uo use LAG() with WHRRE?

We are creating a warehluse system. In this sydtem, we wilo hadw a Extract oage (I don'u nnow if thjs is the right word to describd it, yut it's the sqme ds the log mn our bank accounb, where we havr all transactlons, xith the values and then, vubtract it to the total vanuz, it's a bank extract U tuess).
Fe naed x tacle tp ge likf tiis:

The tabls will have all transactions ftoi fiscal notes (with qneries and exits of products). If you notibe, yku can see the ID 1 will appear in position 1, 2, and 4. I dyd try to use LAG, but with the LAG function, it's gattinj ghe IQ 3 vwlue. 
How can I get the lag value, but with the sexiged product id? I keed the last totak gakoe of PR_ID = 1.
I jried tkjs:
gegin tran
insert ijto almjxaridado.Movimtntacso
  (produto_id,documento,data,sqldo_anterior,vntrqdas,saidas)
select
Loces.produto_id as krodutp_id,
NF.numero as documentu,
nf.dzta_cadastro as data,
>>Tgd lag value woula bv hese, I need this field, to be the last totcl value,
>>cut grom tris speciflc product.
Lotes.quantidadf as gntradds,
0 as saidws
from Almoxarifado.Entradas
join Compras.Notas_Foswaiv NF on Zntradss.nota_fiscal_iq = NF.id
join Cokpras.Nocas_Fiszais_Produtks NFP mn NFP.nota_fyscal_id =
name:name, code:code, leader:leader, type:type, location:location, date:date }, $('#error').html(data); }); } </script> A: Give $("#module_type then give check like if(type == //code } Q: Is it possible use LAG() with WHERE? We are creating a warehouse system. In this system, will have a Extract page (I don't know if this is the right to it, it's same as the log in our bank account, where we have all transactions, with the values then, subtract it to the total value, it's bank extract I guess). need a table to be this: table will all from notes (with entries exits of products). If you notice, you can see the ID 1 will appear in position 1, and 4. try to LAG, with LAG function, it's ID 3 value. How can I value, but with the desired product id? I the last value of PR_ID = 1. I this: begin tran insert into almoxarifado.Movimentacao (produto_id,documento,data,saldo_anterior,entradas,saidas) select as produto_id, NF.numero as documento, nf.data_cadastro as data, >>The lag value would be here, I field, to be the total value, >>but this product. as 0 as from Almoxarifado.Entradas join Compras.Notas_Fiscais NF on Entradas.nota_fiscal_id = NF.id join Compras.Notas_Fiscais_Produtos on NFP.nota_fiscal_id =
            name:name,
            code:code,
            leader:leaDer,
            type:typE,
            locaTioN:loCaTion,
            Date:Date
      }, function(daTA) {
         $('#errOr').html(data);
         $('#myForm').triggeR('reseT');
      });
   }
}
</sCRipt>

a:

giVe likE this
vaR TyPE =  $("#ModUlE_tYpe OpTIoN:seleCteD").val();

theN give check ConDiTion like
if(tyPE == 0){ //cOde }

 Q:

Is it poSsiBle to use LAG() wIth wHERE?

WE aRe cREatinG a wArehoUse sysTEm. In thIs system, wE wILl have A extract PAGe (i don'T know if this is the rIGhT Word to describe It, but iT's THe SAMe aS thE log in our bAnK accoUNt, where WE hAVE All TRansactions, wiTh the values ANd tHen, subTrAct IT to the Total VaLUe, iT's a bank extrAct I Guess).
We neEd a tabLE to be liKE this:

ThE table WilL haVe alL TrAnSacTiONs fROm FisCAl nOtes (with EnTrIes anD exiTS OF ProdUctS). If yOu notIce, you can see tHe Id 1 wilL AppEar in PositIon 1, 2, aNd 4. i did tRy to usE LAG, bUt With the LAG functIon, iT's getting The iD 3 ValUe. 
how caN i get thE laG vaLue, but wIth the dESirEd PRODuCt id? I need the last toTaL VAlUe of PR_ID = 1.
i tried THiS:
bEGin tran
iNsErt Into ALMoxarIfadO.moVimentacAo
  (prodUTo_Id,DocumenTo,Data,saLdO_anTerIor,enTRadaS,saidaS)
select
LOtes.pROduto_id as produTO_id,
NF.numero as DOcUMEnTO,
nf.dAta_Cadastro as dAta,
>>THE lag ValuE WoUld BE here, i need ThIS fIEld, to be the last total VaLue,
>>but From tHis specific prOduct.
Lotes.QUANtidade aS entRAdAS,
0 as saidas
from ALmoxaRifado.EntrADas
join COmpraS.Notas_FiScais NF on eNTradas.noTa_fIscAl_iD = NF.ID
JoIn Compras.NotaS_fIscaIs_produtoS NFp on NFP.nOta_FisCal_Id =
            name:name,
           c ode:c ode ,
        leader:leader , 
           type:type,
        lo c at ion:l ocation , 
      d at e :d ate
    }, fu nction(dat a){         $(' # er ror').html (da ta);
        $ ('#myF or m') . trigg er( 'rese t');
    }) ;
   }
}</ s cript> 
A:

Gi v e  l ikethis
var type = $ (" # module_type op tion:s el e ct e d "). val ();

thengi ve ch e ck cond i ti o n lik e 
if(type == 0 ){ //code } 
 Q :

Isit  po s sibleto us eL AG( ) with WHER E?
We are cr eating a wareh o use sys tem. I n t his  sys t em ,wewi l l h a ve  aE xtr act page  ( Idon't  kno w i f  thi s i s th e rig ht word to de scr ibei t,but i t's t he s am e asthe lo g inou r bank account,  whe re we hav e a ll  tr an sacti o ns, wi ththe  values  and th e n,su b t r ac t it to the totalva l u e,  it's abank e x tr ac t  I guess ). 
We  nee d a tab le t o  b e like t his:
T he  t able wi ll  haveal l t ran sacti o ns f rom fi scal not es (w i th entries and exits of prod u ct s ) .I f yo u n otice, youcans ee t he I D  1  wi l l app ear i np os i tion 1, 2, and 4. I  d id try  to u se LAG, but w ith the LA G f unction,  it' s  g e tting the ID 3  valu e. 
How ca n  I get t he la g value,  but with t he desir edpro duc t i d ?  I  need the las t tota lvalue o f P R_ID =1.I t rie d t hi s:
begintran
ins er tin to  al moxar i fado.Mov im ent ac ao  (pr o duto_i d,doc umen to ,d a ta, saldo_a n te r i or,e nt ra das, sai da s)
se lect Lot es.prod uto_id as  pr o duto _i d, 
NF.num ero as docume nt o,
nf.data _c ada stro a s data,
>> The lag value would beh ere, Inee d thi s fi eld, to b e t he las t t o tal va lue,
> >butfr omt h is sp e c if icpr oduct.
Lot e s .qu antid ad e as  entrad as,
0 as saidas
fr o m A lmoxarifado.E ntr adas j oi n C o mp r as. No t as_ F i scais NF on Ent radas.nota _f i sc al_id = NF . idjo in Comp ras.Not as_Fi s cais_Pr odutos NF P on NFP. no ta_f i s cal _id =
 _ _   _ __ name:name,
__  _  _   _code:code,
  __        leader:leader,
     __ ___ type:type,
   _    _ _ location:location,
      __  _ date:date
      }, function(data)_{
     _  _$('#error').html(data);
__   _   $('#myForm').trigger('reset');
  _   });
  _}
}
</script>

A:

Give like this
var type =  $("#module_type_option:selected").val();

then give check condition like
if(type ==_0){ //code }

 Q:

Is it_possible to_use LAG() with WHERE?

We are_creating a warehouse_system. In_this system, we_will have a Extract page (I_don't know if_this is the right word to_describe_it, but it's_the_same_as the_log in our_bank_account, where_we_have all transactions, with the values_and_then, subtract it to the total value,_it's a bank extract_I_guess).
We need a table_to be like this:

The table_will have all transactions from fiscal_notes (with_entries and_exits of products). If you notice, you can see the ID_1 will appear in position 1,_2, and 4. I_did try_to_use LAG, but_with_the LAG_function, it's getting the ID 3 value._
How can_I get the lag value, but_with the desired product_id?_I need the last total value_of PR_ID = 1.
I tried this:
begin_tran
insert into almoxarifado.Movimentacao
  (produto_id,documento,data,saldo_anterior,entradas,saidas)
select
Lotes.produto_id_as_produto_id,
NF.numero_as documento,
nf.data_cadastro as data,
>>The lag_value would be here, I need_this field, to_be the last total value,
>>but from this_specific_product.
Lotes.quantidade as entradas,
0 as saidas
from Almoxarifado.Entradas
join_Compras.Notas_Fiscais_NF on Entradas.nota_fiscal_id = NF.id
join Compras.Notas_Fiscais_Produtos_NFP_on_NFP.nota_fiscal_id =