Click here to Skip to main content
15,902,189 members
Home / Discussions / Database
   

Database

 
Rant[REPOST] Database backed up type virtual device- not mainteance job Pin
Richard Deeming27-Jun-16 3:56
mveRichard Deeming27-Jun-16 3:56 
Questioncall sql scripts from others folders Pin
MrKBA19-Jun-16 23:43
MrKBA19-Jun-16 23:43 
QuestionRe: call sql scripts from others folders Pin
CHill6020-Jun-16 1:41
mveCHill6020-Jun-16 1:41 
AnswerRe: call sql scripts from others folders Pin
MrKBA20-Jun-16 2:30
MrKBA20-Jun-16 2:30 
AnswerRe: call sql scripts from others folders Pin
Eddy Vluggen20-Jun-16 1:46
professionalEddy Vluggen20-Jun-16 1:46 
GeneralRe: call sql scripts from others folders Pin
MrKBA20-Jun-16 2:29
MrKBA20-Jun-16 2:29 
GeneralRe: call sql scripts from others folders Pin
Eddy Vluggen20-Jun-16 2:40
professionalEddy Vluggen20-Jun-16 2:40 
AnswerRe: call sql scripts from others folders Pin
CHill6020-Jun-16 3:41
mveCHill6020-Jun-16 3:41 
QuestionPrioritized joining - Updated Pin
Jörgen Andersson16-Jun-16 9:39
professionalJörgen Andersson16-Jun-16 9:39 
AnswerRe: Prioritized joining Pin
Mycroft Holmes16-Jun-16 13:05
professionalMycroft Holmes16-Jun-16 13:05 
GeneralRe: Prioritized joining Pin
Jörgen Andersson16-Jun-16 21:58
professionalJörgen Andersson16-Jun-16 21:58 
GeneralRe: Prioritized joining Pin
Mycroft Holmes17-Jun-16 2:52
professionalMycroft Holmes17-Jun-16 2:52 
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 
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 
You have a problem with your Unpivot - try removing 'Student' from the column list i.e.
SQL
Unpivot(Course for Courses in (English, Physics, Mathematics, Engineering))as upv

There is also a problem with the Pivot - you need to use a summary function e.g.
C#
Pivot(MAX(course) for Student in (Jane, Michelle, Dan)) as pv

Unfortunately if you fix those two problems you get the following results
ID	Courses		Jane	Michelle Dan
1	Engineering	A	NULL	NULL
2	Engineering	NULL	A	NULL
3	Engineering	NULL	NULL	B
1	English		A	NULL	NULL
2	English		NULL	A	NULL
3	English		NULL	NULL	A
1	Mathematics	A	NULL	NULL
2	Mathematics	NULL	B	NULL
3	Mathematics	NULL	NULL	A
1	Physics		B	NULL	NULL
2	Physics		NULL	A	NULL
3	Physics		NULL	NULL	A

This is where the article mentioned by @Mycroft-Holmes comes into play OR you can fiddle it like this
SQL
select Courses, MAX(ISNULL(Jane,'')) as Jane, MAX(ISNULL(Michelle,'')) as Michelle, MAX(ISNULL(Dan,'')) as Dan
from 
	(Select * from TestScores
	Unpivot(Course for Courses in (English, Physics, Mathematics, Engineering))
	as upv ) UPV
Pivot(MAX(Course) for Student in (Jane, Michelle, Dan)) as pv
GROUP BY Courses

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 

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.