Case Sqlserver, how to proceed?

Asked

Viewed 80 times

2

I am trying to display a column q is set at 0 and 1 so that when by 0 show 'Ok' and for when it is 1 'NOK'.

Follow my code that is not working, but by the query slq

String query1 = "Select DATA,HORA,RCPERFIL,BPCS,N_ETIQUETA,EMV_MIN,EMV_MAX,TMV,"
    + "ET5_MIN,ET5_MAX,TT5,"
    + "ETS2_MIN,ETS2_MAX,TTS2,"
    + "ET90_MIN, ET90_MAX,TT90,"
    + "EDENS_MIN,EDENS_MAX,TDENS,[EC-CHART],EBLOOMING = (CASE when EBLOOMING = '0 'then 'ok' else 'nok' END from
       QRY_MIX_LCSOMA where CONTAGEM_APROV = '0' and TIPOTESTE = 'Filtrado'
       ORDER BY DATA,HORA DESC";
  • 1

    ta returning any error? or always displays ok?

  • by SQL displays perfectly, but by IDE, says q the syntax is wrong in 'FROM'

  • What is the IDE? What language are you using to run the query? The problem may be occurring due to concatenation there

  • I am using the 'Netbeans' IDE with java programming and using the JDBC method

  • 1

    was looking at your query and is missing a close parentheses after the END

  • Yes, you’re right.. but when I closed it, it was another mistake, but I think I know.. I think that’s why I declared the column as int

  • that’s right, sorry for the post

Show 2 more comments

1 answer

2


I noticed that your select missed closing (), as this using a subselect is necessary to use the select clause and your case is checking '0 ' and not '0', basing me on sql server your subselect would look like this:

(SELECT CASE when EBLOOMING = '0' then 'ok' else 'nok' AS NOMECOLUNA END from
       QRY_MIX_LCSOMA where CONTAGEM_APROV = '0' and TIPOTESTE = 'Filtrado')

NOTE: I removed the order by as a subselect

Browser other questions tagged

You are not signed in. Login or sign up in order to post.