I have a table customer with columns fname,lname, tipo, kode
I want a list all the customer with fname, tipo, approved
tipo is with populated with 'teacher' or 'student'
the third column should be taken from tipo and kode that menas if tipo is 'teacher' result ' ', if tipo is 'student and from the kode the 4-th and 5-th caracter are <10 return 'false' else return 'true'
how can I do this only with select without functions or stored procedures
select fname, tipo,
(select (case when SUBSTRING(kode, 4, 2) < 40 and tipo='student' then 'true'
when SUBSTRING(kode, 4, 2) <= 40 and tipo='student' then 'false'
else ' ' end) as approved from customer )
from customer
;
but returns me an error "
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
"
thanks in advance