Creating view when view columns are referring to a single column of a table with different where conditions

39 views Asked by At

I need to create a view: employee_view

CREATE VIEW employee_view (Name_of_employee, Name_of_PL, Name_of_manager)
AS 
(
Need help here!
)

Raj is an employe
Vijay is a PL
Kumar is a manager

The data for the view columns are coming from a single column of a table but with different where conditions. I need to create a view. Please help, table is mentioned below.

table name: employee

compid secid rowid fieldname
22      1    6     Raj
22      2    7     Vijay
22      3    8     Kumar
1

There are 1 answers

0
curiousboy On
CREATE VIEW employee_view (Name_of_employee, Name_of_PL, Name_of_manager)
AS 
SELECT
(select fieldname from employee where secid=1 and rowid=6),
(select fieldname from employee where secid=2 and rowid=7),
(select fieldname from employee where secid=3 and rowid=8)

I got the answer myself, refer this if anyone run into this situation.