I've provided statements to create the two example tables for my question below.
In this example, the second table contains the same student id multiple times due to having multiple classIDs. However, I need the query results to be displayed horizontally on one row. (The max # of classID's per studentid is 15)
How would you write a select statement that joins the two tables and all classID data repeats within the same column like the example below:
CREATE TABLE Student (
StudentId int,
FirstName VarChar (255),
LastName VarChar (255)
);
CREATE TABLE Classes (
StudentId int,
ClassId int,
ClassName VarChar (255),
ClassCost int
);
INSERT INTO Student (StudentId, FirstName, LastName)
VALUES
(123, 'Carol', 'Dwek'),
(456, 'Cal', 'Newport');
INSERT INTO Classes (StudentId, ClassId, ClassName,ClassCost)
VALUES
(123, 972, 'Psychology',30),
(456, 214, 'Focus',99),
(123, 903, 'Sociology',30),
(456, 851, 'Meditation',99),
(456, 911, 'Reading',20),
(456, 111, 'Deep Work',50),
(456, 117, 'Time Management',25),
(456, 999, 'Goal Setting',50);