How to do a counter SQL Server 2008? -


i have been doing this

select       movi.usuario rowusuario, movi.movid, min(art.descripcion1),      min(com.referenciaextra), min(com.unidad), min(art.unidadcompra),      min(movi.fechaemision),      error = case          when min (com.unidad) not              case                when min (ar.unidad) com.unidad art.unidad             end         1        else 0     end      comprad com inner join      mov movi on com.id = movi.id inner join      art on com.articulo = art.articulo      movi.mov = 'requisicion order      movi.fechaemision asc 

`when 'com.unidad' dont match art.unidad, add 1 or 0 if match

sql server says:

incorrect syntax case

the incorrect syntax error referring

error = case part.  

it should

case statement end error 

however i'm not sure if solve problem case statements looks little odd me bit right way around , let know of further error messages.

possibly...

sum(case when com.unidad <> ar.unidad 1 else 0 end error) 

also, missing group clause, if want use aggregate functions (min example) need group non aggregate fields.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -