2

how can i make a select from not normed table.

i have the table like this:

enter image description here

this table is not norme BNF 2.

i just want to select the NO_ID where DEPARTEMENT = something. example:
when the input 44 then NO_ID =1
when the input 37 then NO_ID =3
when the input 13(not in table) then NO_ID = 5

of course when input = 44 it works:

SELECT [NO_ID]    
FROM [T_TARIF_ZONE]
WHERE DEPARTEMENT = '44'

but how can i put in WHERE statement when the input = 37 or 13.

thanks you in advance, Stev

2
  • I think you need to get NO_ID values where DEPARTMENT number exists in DEPARTMENT number string? Commented Apr 19, 2013 at 8:39
  • On what basis NO_ID 5 is selected for input 13? Commented Apr 19, 2013 at 8:54

3 Answers 3

1

try this:

SELECT [NO_ID]    
FROM [T_TARIF_ZONE]
WHERE DEPARTEMENT like '%37%'
Sign up to request clarification or add additional context in comments.

2 Comments

thanks you, yes you right, but how can i retrun 5 when the value is not in Departement example 13
This would fail if there is a '371' code in there - I don't know if that applies here.
1

Please try:

select 
    NO_ID, 
    DEPARTMEMT 
from 
    T
where 
    ' '+DEPARTMEMT+' ' like 
    (case when @var=13 then ' FRANCE ' ELSE '% '+@var+' %' END)

Comments

0

Oracle version -

SELECT [NO_ID]    
FROM [T_TARIF_ZONE]
WHERE INSTR(DEPARTEMENT, '44')>0  OR INSTR(DEPARTEMENT, '37')>0 OR INSTR(DEPARTEMENT, '13')>0 

SQL Server version -

    SELECT [NO_ID]    
FROM [T_TARIF_ZONE]
WHERE PATINDEX('44', DEPARTEMENT)>0  OR PATINDEX('37', DEPARTEMENT)>0 OR PATINDEX('13', DEPARTEMENT)>0 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.