Skip to content
Advertisement

Which SQL function I should use to repeat existing row values for a new column

I have a table with 2 column studentID and StudentName and department.

I would like to create a view based on Student table where I would like to have StudentID,StudentName and a Category Column that has 4 values as follows:

A,B,C,D

In the final view I would like to have above category assigned to each Student something like below

Advertisement

Answer

Just use a cross join. In most databases you can do something like this:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement