I want to add one more case on my query. if phone number have product which have FACE, FAST and MOBIL, add 10 point on answer1 alias column.
How can I do that I think I should use union but I can't do algorith
I explain other case
if product is equal FAST and tree_level is equal 0,1,2,3,4,5 and tree_level equal -1 point is 2
and if product is equal MOBIL and tree_level is equal 0,1,2,3,4,5 point is 3
if product is equal FACE and tree_level is equal 0,1,2,3,4,5 point is 3 and tree_level equal -1 point is 2
ı want to add if number's product have face,mobil,fast product give 10 point
produc.DIG_SEF table
product|phone|tree_lev | start_date | end_date
___________________________________________________________________________
fast |98998|0 |2013-06-15 00.00.00.0000 |2013-09-15 00.00.00.0000
mobil |98998|0 |2013-06-15 00.00.00.0000 |2013-09-15 00.00.00.0000
face |98998|0 |2013-06-15 00.00.00.0000 |2013-09-15 00.00.00.0000
face |54545|1 |2013-09-15 00.00.00.0000 |2013-12-15 00.00.00.0000
mobil |66545|2 |2013-12-15 00.00.00.0000 |2014-03-15 00.00.00.0000
mobil |26545|2 |2013-12-15 00.00.00.0000 |2014-03-15 00.00.00.0000
face |43645|1 |2013-09-15 00.00.00.0000 |2013-12-15 00.00.00.0000
face |34545|1 |2013-09-15 00.00.00.0000 |2013-12-15 00.00.00.0000
mobil |26545|2 |2013-12-15 00.00.00.0000 |2014-03-15 00.00.00.0000
face |56898|-1 |2014-03-15 00.00.00.0000 |2014-06-15 00.00.00.0000
For Example, phone 98998 have FACE, MOBIL and FAST. I want to give 10 point on answer1
select
DS.phone,
DS.Product,
DS.Tree_lev,
CASE
WHEN DS.Tree_lev IN (-1) And DS.Product LIKE '%FACE%' THEN 2
WHEN DS.Tree_lev IN (-1) And DS.Product LIKE '%FAST%' THEN c 2
WHEN DS.Tree_lev >=0 AND DS.Product LIKE '%FACE%' THEN 3
WHEN DS.Tree_lev >=0 AND DS.Product LIKE '%MOBIL%' THEN 3
WHEN DS.Tree_lev AND DS.Product LIKE '%FAST%' THEN 2
Else DS.Tree_lev
END AS Answer1
from produc.DIG_SEF AS DS
my query give this output
product|phone|tree_lev | answer1
___________________________________________________________________________
fast |98998|0 |2
mobil |98998|0 |3
face |98998|0 |3
face |54545|-1 |2
mobil |66545|2 |3
mobil |26545|3 |3
ı want this output
product |phone| answer1
___________________________________________________________________________
fast |98998|2
mobil |98998|3
face |98998|3
threproduct |98998|10 // **ı want to add this**
face |54545|2
mobil |66545|3
mobil |26545|3