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

Database

 
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 
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 
GeneralRe: Call dll from SQL trigger Pin
Richard Deeming1-Jun-16 4:14
mveRichard Deeming1-Jun-16 4:14 
QuestionJoining three tables Pin
Raabi Anony27-May-16 2:27
Raabi Anony27-May-16 2:27 

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.