Skip to content
Advertisement

I don’t know how to combine my attributes into a single column for this query

My query is to Produce a list of Employees who work for the cinema with the cinema number 07 and include the cinema name in the result. Arrange the result in ascending order by employee surname. Name attributes should be combined into a single output column, and given a sensible header. I’ve answered most of the query but I’m stuck on the last part . Can somebody help me on this .

  SELECT Employee.Cinema_No, Cinema.Cinema_Name, Employee.First_Name, 
  Employee.Surname
  FROM Employee
  INNER JOIN Cinema ON Employee.Cinema_No = Cinema.Cinema_No
  WHERE Employee.Cinema_No = 7
  ORDER BY Surname ASC ; 

Advertisement

Answer

All that is left to do is to concatenate the First and Last name of the employee into a single column. For this, Oracle provides the || operator (string concatenation). You can then use an alias to choose a sensible column name, using keyword AS.

Query :

SELECT 
    Employee.Cinema_No, 
    Cinema.Cinema_Name, 
    Employee.First_Name || ' ' ||  Employee.Surname AS Employee_Full_Name
FROM Employee
INNER JOIN Cinema ON Employee.Cinema_No = Cinema.Cinema_No
WHERE Employee.Cinema_No = 7
ORDER BY Surname ASC ; 
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement