Duda Select SQL

0

I'm new here. I'm not very skilled in SQL. I hope someone can help me

I want to make a query to the same column (star_result) but separate the results depending on whether the column rating_item_id has a value 2 (Importance) or 3 (Urgency)

SELECT star_result AS Importancia,star_result AS Urgencia
FROM ycdxw_mrp_rating_result
WHERE rating_item_id = "2" OR rating_item_id = "3"

The problem is that I do not know how I can assign in WHERE the 2 to the alias Importance and the 3 to the alias Urgency. I get both results in the two columns:

Thank you very much from now ...

    
asked by Cuatrocento 05.04.2017 в 14:06
source

1 answer

0

It may serve you something like the following query. Although without a pivot column, you will not see a flat table as a result.

SELECT 
    Importancia = case rating_item_id when 2 then star_result else null end, 
    Urgencia  = case rating_item_id when 3 then star_result else null end
FROM ycdxw_mrp_rating_result
WHERE rating_item_id = "2" OR rating_item_id = "3"
    
answered by 05.04.2017 в 14:19