1

I have a table with Last Names, First Names, Hours and GPA's.

How do I create a view that displays a concatenated first name and last name, the StudentID and the GPA of the students who have passed at least 90 hours.

The concatenated names should be separated with one space. The three column headings should be FullName, StudentID and GPA. The rows should be sorted by last names, then first names.

Please help. I am lost as to how to approach this.

5
  • 1
    What have you tried? What part of the task is causing you a problem? Do you know how to create a view from a query, for example, but don't know how to write this query? Do you know how to write a select statement in general? Are you just trying to understand the syntax for concatenating strings in Oracle SQL? Commented Jul 1, 2015 at 16:17
  • 1
    see also: stackoverflow.com/questions/1619259/… Commented Jul 1, 2015 at 16:21
  • The problem is that when I create the view, it doesn't display the real name, it just says FirstNameLastName, it displays the other values correctly but not the concat name Commented Jul 1, 2015 at 17:16
  • If it just says literally FirstNameLastName for every row it means you're passing the strings "FirstName" and "LastName" instead of the variables for first name and last name as arguments to concat Commented Jul 1, 2015 at 18:50
  • Edit your question to include what you have tried. Commented Jul 1, 2015 at 19:42

1 Answer 1

2

Use the operator || for concatenation (so you don't have to do nested CONCAT()).

Example:

create view v as 
    select (firstname || ' ' || lastname) "FullName", GPA, StudentId 
    from table
    where Hours>90
    order by lastname, firstname
Sign up to request clarification or add additional context in comments.

2 Comments

Do you know why it shows the full name as FirstNameLastName instead of the real values
Is it possible that you're passing character strings like "FirstName" instead of variable names like FirstName into your select statement? Check your quotation marks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.