Click here to Skip to main content
15,910,981 members
Home / Discussions / Database
   

Database

 
AnswerRe: Delta between records in one column Pin
Wendelius26-Mar-11 22:07
mentorWendelius26-Mar-11 22:07 
GeneralRe: Delta between records in one column Pin
Member 377323026-Mar-11 22:24
Member 377323026-Mar-11 22:24 
GeneralRe: Delta between records in one column Pin
Wendelius26-Mar-11 22:42
mentorWendelius26-Mar-11 22:42 
GeneralRe: Delta between records in one column Pin
Member 377323026-Mar-11 23:16
Member 377323026-Mar-11 23:16 
GeneralRe: Delta between records in one column Pin
Wendelius26-Mar-11 23:38
mentorWendelius26-Mar-11 23:38 
AnswerRe: Delta between records in one column Pin
Jörgen Andersson27-Mar-11 8:26
professionalJörgen Andersson27-Mar-11 8:26 
GeneralRe: Delta between records in one column [modified] Pin
Member 377323027-Mar-11 22:34
Member 377323027-Mar-11 22:34 
QuestionPivot? Pin
Andy_L_J26-Mar-11 14:56
Andy_L_J26-Mar-11 14:56 
I always struggle when it comes to PIVOTs (as I am pretty sure that is what is required).

I have the following query:

SQL
WITH plant As 
	(SELECT mp.ID, mp.MixPlant_Name
		FROM MixPlant mp
		WHERE mp.IsActive = 1)
SELECT DISTINCT(mp.MixDate), plant.MixPlant_Name, SUM(mp.NoMixes) As No
	FROM MixProduction mp
		JOIN plant
			ON mp.MixPlant_ID = plant.ID
	WHERE mp.MixDate BETWEEN '2/22/2011' AND '2/23/2011'
	Group By plant.MixPlant_Name, mp.MixDate
Go


which produces the following result:
MixDate				MixPlant_Name	No
2011-02-22 00:00:00.000		MTI		88
2011-02-22 00:00:00.000		Plasmec		116
2011-02-22 00:00:00.000		Prodex		27
2011-02-23 00:00:00.000		MTI		69
2011-02-23 00:00:00.000		Plasmec		121
2011-02-23 00:00:00.000		Prodex		15


I am looking to get the following output:
MixDate                        MTI             Plasmec       Prodex
2011-02-22 00:00:00.000	       88	       116	     27
2011-02-23 00:00:00.000	       36	       121	     15


Any suggestions, links or gentle sarcasm appreciated.

I don't speak Idiot - please talk slowly and clearly

'This space for rent'

Driven to the arms of Heineken by the wife

AnswerRe: Pivot? Pin
Mycroft Holmes26-Mar-11 19:56
professionalMycroft Holmes26-Mar-11 19:56 
GeneralRe: Pivot? Pin
Andy_L_J27-Mar-11 18:18
Andy_L_J27-Mar-11 18:18 
GeneralRe: Pivot? Pin
Andy_L_J27-Mar-11 23:47
Andy_L_J27-Mar-11 23:47 
QuestionWhat are solutions for a way-too-big database? Pin
bobbi200426-Mar-11 7:23
bobbi200426-Mar-11 7:23 
AnswerRe: What are solutions for a way-too-big database? Pin
Wendelius26-Mar-11 7:41
mentorWendelius26-Mar-11 7:41 
GeneralRe: What are solutions for a way-too-big database? Pin
bobbi200426-Mar-11 16:20
bobbi200426-Mar-11 16:20 
AnswerRe: What are solutions for a way-too-big database? Pin
PIEBALDconsult26-Mar-11 17:21
mvePIEBALDconsult26-Mar-11 17:21 
GeneralRe: What are solutions for a way-too-big database? Pin
bobbi200427-Mar-11 6:53
bobbi200427-Mar-11 6:53 
AnswerRe: What are solutions for a way-too-big database? Pin
Klaus-Werner Konrad31-Mar-11 8:42
Klaus-Werner Konrad31-Mar-11 8:42 
QuestionMultiple selection from the same table Pin
CodingLover25-Mar-11 19:43
CodingLover25-Mar-11 19:43 
AnswerRe: Multiple selection from the same table Pin
Аslam Iqbal26-Mar-11 0:14
professionalАslam Iqbal26-Mar-11 0:14 
AnswerRe: Multiple selection from the same table Pin
Wendelius26-Mar-11 0:53
mentorWendelius26-Mar-11 0:53 
AnswerRe: Multiple selection from the same table Pin
Luc Pattyn26-Mar-11 7:27
sitebuilderLuc Pattyn26-Mar-11 7:27 
GeneralRe: Multiple selection from the same table Pin
Wendelius26-Mar-11 7:45
mentorWendelius26-Mar-11 7:45 
GeneralRe: Multiple selection from the same table Pin
Luc Pattyn26-Mar-11 8:05
sitebuilderLuc Pattyn26-Mar-11 8:05 
GeneralRe: Multiple selection from the same table Pin
Wendelius26-Mar-11 8:07
mentorWendelius26-Mar-11 8:07 
Questiondynamically change column name Pin
amit sahu2025-Mar-11 1:16
amit sahu2025-Mar-11 1:16 

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.