Occupation test

0

Please login or register to vote for this query.

(click on this box to dismiss)

Joomla

Q&A for Joomla! administrators, users, developers and designers

CREATE TABLE #occupations (
  name varchar(30) DEFAULT NULL,
  occupation varchar(30) DEFAULT NULL
)
INSERT INTO #occupations (name, occupation) VALUES
('Samantha', 'Doctor'),
('Julia', 'Actor'),
('Maria', 'Actor'),
('Meera', 'Singer'),
('Ashley Professor', NULL),
('Ketty', 'Professor'),
('Christeen', 'Professor'),
('Ketty', 'Professor'),
('Christeen', 'Professor'),
('Jane', 'Actor'),
('Jenny', 'Doctor'),
('Priya', 'Singer')

SELECT *
FROM
(
SELECT [Name], [Occupation] 
FROM #occupations 
) AS source
PIVOT
(
    max([Name])
    FOR [occupation] IN ([Doctor], [Professor], [Singer], [Actor]) 
) as pvt;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results