Click here to Skip to main content
15,888,527 members
Home / Discussions / Database
   

Database

 
GeneralRe: Prioritized joining Pin
Jörgen Andersson17-Jun-16 3:59
professionalJörgen Andersson17-Jun-16 3:59 
GeneralRe: Prioritized joining Pin
Jörgen Andersson29-Jun-16 10:28
professionalJörgen Andersson29-Jun-16 10:28 
AnswerRe: Prioritized joining - Updated Pin
Richard Deeming17-Jun-16 1:57
mveRichard Deeming17-Jun-16 1:57 
GeneralRe: Prioritized joining - Updated Pin
Jörgen Andersson17-Jun-16 3:30
professionalJörgen Andersson17-Jun-16 3:30 
GeneralRe: Prioritized joining - Updated Pin
Richard Deeming17-Jun-16 12:29
mveRichard Deeming17-Jun-16 12:29 
GeneralRe: Prioritized joining - Updated Pin
Jörgen Andersson18-Jun-16 4:18
professionalJörgen Andersson18-Jun-16 4:18 
GeneralRe: Prioritized joining - Updated Pin
Jörgen Andersson29-Jun-16 10:44
professionalJörgen Andersson29-Jun-16 10:44 
QuestionPivot Not Working Pin
MadDashCoder11-Jun-16 8:01
MadDashCoder11-Jun-16 8:01 
I have a database table with the following schema
SQL
CREATE TABLE [dbo].[TestScores](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Student] [nvarchar](25) NOT NULL,
	[English] [nvarchar](25) NULL,
	[Physics] [nvarchar](25) NULL,
	[Mathematics] [nvarchar](25) NULL,
	[Engineering] [nvarchar](25) NULL,
	PRIMARY KEY (ID)
 )

// Sample Data
Insert Into TestScores (Student, English, Physics, Mathematics, Engineering)
Values ('Jane', A, B, A, A);

Insert Into TestScores (Student, English, Physics, Mathematics, Engineering)
Values ('Michelle', A, A, B, A);

Insert Into TestScores (Student, English, Physics, Mathematics, Engineering)
Values ('Dan, A, A, A, B);


I would like to display the results like the following
Student       Jane  Michelle  Dan

English       A     A         A

Physics       B     A         A

Mathematics   A     B         A

Engineering   A     A         B


I wanted to first Unpivot the data then Pivot the data but I just could not use the Pivot operator on the given data.

Below is my query
SQL
Select * from TestScores
Unpivot(Course for Courses in (Student, English, Physics, Mathematics, Engineering))as upv
Pivot(course for Student in (Jane, Michelle, Dan)) as pv


modified 12-Jun-16 9:19am.

AnswerRe: Pivot Not Working Pin
Mycroft Holmes11-Jun-16 14:51
professionalMycroft Holmes11-Jun-16 14:51 
AnswerRe: Pivot Not Working Pin
CHill6012-Jun-16 0:33
mveCHill6012-Jun-16 0:33 
GeneralRe: Pivot Not Working Pin
MadDashCoder12-Jun-16 3:56
MadDashCoder12-Jun-16 3:56 
GeneralRe: Pivot Not Working Pin
CHill6012-Jun-16 4:43
mveCHill6012-Jun-16 4:43 
GeneralRe: Pivot Not Working Pin
MadDashCoder12-Jun-16 8:36
MadDashCoder12-Jun-16 8:36 
GeneralRe: Pivot Not Working Pin
CHill6012-Jun-16 8:54
mveCHill6012-Jun-16 8:54 
GeneralRe: Pivot Not Working Pin
Mycroft Holmes12-Jun-16 12:58
professionalMycroft Holmes12-Jun-16 12:58 
QuestionDatabase backed up type virtual device- not mainteance ? Pin
SreeDBA5-Jun-16 5:28
SreeDBA5-Jun-16 5:28 
AnswerRe: Database backed up type virtual device- not mainteance ? Pin
Richard Deeming6-Jun-16 5:13
mveRichard Deeming6-Jun-16 5:13 
Questionsyntax error for simple IF - THEN Pin
Jassim Rahma1-Jun-16 7:50
Jassim Rahma1-Jun-16 7:50 
AnswerRe: syntax error for simple IF - THEN Pin
thatraja1-Jun-16 9:04
professionalthatraja1-Jun-16 9:04 
GeneralRe: syntax error for simple IF - THEN Pin
Jassim Rahma1-Jun-16 21:01
Jassim Rahma1-Jun-16 21:01 
GeneralRe: syntax error for simple IF - THEN Pin
Peter_in_27801-Jun-16 21:13
professionalPeter_in_27801-Jun-16 21:13 
GeneralRe: syntax error for simple IF - THEN Pin
thatraja3-Jun-16 5:50
professionalthatraja3-Jun-16 5:50 
QuestionCall dll from SQL trigger Pin
srikrishnathanthri31-May-16 19:49
srikrishnathanthri31-May-16 19:49 
AnswerRe: Call dll from SQL trigger Pin
Richard Deeming1-Jun-16 2:39
mveRichard Deeming1-Jun-16 2:39 
GeneralRe: Call dll from SQL trigger Pin
srikrishnathanthri1-Jun-16 4:04
srikrishnathanthri1-Jun-16 4:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.