Click here to Skip to main content
15,901,666 members
Home / Discussions / Database
   

Database

 
AnswerRe: MS Access permissions issue...? Pin
Krish - KP25-Feb-08 16:44
Krish - KP25-Feb-08 16:44 
GeneralRe: MS Access permissions issue...? Pin
ChandraRam25-Feb-08 17:55
ChandraRam25-Feb-08 17:55 
GeneralSQL 2005 Login Issue [modified] Pin
Brady Kelly25-Feb-08 0:37
Brady Kelly25-Feb-08 0:37 
GeneralRe: SQL 2005 Login Issue Pin
User 27100925-Feb-08 0:50
User 27100925-Feb-08 0:50 
GeneralRe: SQL 2005 Login Issue Pin
Jacquers25-Feb-08 0:53
Jacquers25-Feb-08 0:53 
GeneralOT: SQL 2005 Login Issue Pin
RichardGrimmer25-Feb-08 1:22
RichardGrimmer25-Feb-08 1:22 
GeneralRe: OT: SQL 2005 Login Issue Pin
Brady Kelly25-Feb-08 1:40
Brady Kelly25-Feb-08 1:40 
QuestionHow to get the varbinary value from SQLServer2005 and display that string in WebForm? Pin
Tamizh24-Feb-08 23:14
Tamizh24-Feb-08 23:14 
QuestionRe: How to get the varbinary value from SQLServer2005 and display that string in WebForm? Pin
pmarfleet25-Feb-08 2:10
pmarfleet25-Feb-08 2:10 
Questiontable datatype in sp sql server Pin
Sonia Gupta24-Feb-08 23:04
Sonia Gupta24-Feb-08 23:04 
GeneralRe: table datatype in sp sql server Pin
Joe25-Feb-08 1:06
Joe25-Feb-08 1:06 
GeneralFinding Database name Pin
alok_2k324-Feb-08 19:59
alok_2k324-Feb-08 19:59 
GeneralRe: Finding Database name Pin
Giorgi Dalakishvili24-Feb-08 20:14
mentorGiorgi Dalakishvili24-Feb-08 20:14 
GeneralRe: Finding Database name Pin
alok_2k324-Feb-08 20:23
alok_2k324-Feb-08 20:23 
GeneralRe: Finding Database name Pin
Giorgi Dalakishvili24-Feb-08 20:25
mentorGiorgi Dalakishvili24-Feb-08 20:25 
GeneralQuery result not as expected [modified] Pin
Andy_L_J23-Feb-08 17:35
Andy_L_J23-Feb-08 17:35 
I am attempting to get a result set from a query and it is not how I expected. (Go figure!)

Tables Structure:

Production: Date, WOID (FK)

WorkOrder: WOID (PK), ProdID (FK)

Product: ProdID (PK), PCatID (FK)

Category: PCatID (PK), Category

FormTrans: Date, WOID (FK), Kgs

I want to return results in the following Table structure:

Date, CategoryA, CategoryC, CategoryC,..., CategoryN, Date Kgs, Ave, Running Total


I have tried the following:

DECLARE @Start DateTime,
@End DateTime

SET @Start = '01/01/2007'
SET @End = '12/31/2007'

Select Distinct(pr.[Date],
Case When pc.Category IN ('Mini','Maxi','OSCS')
Then SUM(ft.Kgs)
Else 0
End As 'DUCT',
Case When pc.Category IN ('DSPETG','DSPVC')
Then SUM(ft.Kgs)
ELSE 0
END AS 'DS",
SUM(ft.Kgs) As 'Kgs' -- Date Kgs
-- Average for distinct date required here?
-- Running Total for Dates here?
FROM Production pr
JOIN WorkOrder wo
ON pr.WOID = wo.WOID
JOIN Product p
ON wo.ProdID = p.ProdID
JOIN ProdCategory pc
ON p.PCatID = pc.PCatID
JOIN Formula f
ON wo.FormulaID = f.FormulaID
JOIN FormTrans ft
ON ft.FormulaID = f.FormulaID

WHERE pr.[Date] BETWEEN @Start AND @End
GROUP BY pr.[Date],pc.Category
ORDER BY pr.Date

1, When I run this I am getting data but a single line for each category calculation per date and not a single date row for each date with multiple results on the same row.

2, How to implement the average, and running total columns?

I hope I have explained myself clearly. Confused | :confused: Unsure | :~

Any help is most appreciated.

Andy.

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

modified on Monday, February 25, 2008 1:29 AM

GeneralRe: Query result not as expected Pin
GuyThiebaut24-Feb-08 11:18
professionalGuyThiebaut24-Feb-08 11:18 
GeneralRe: Query result not as expected Pin
Andy_L_J24-Feb-08 13:28
Andy_L_J24-Feb-08 13:28 
GeneralHelp with this select Pin
Caio Vitor23-Feb-08 5:25
Caio Vitor23-Feb-08 5:25 
GeneralRe: Help with this select Pin
Caio Vitor23-Feb-08 6:34
Caio Vitor23-Feb-08 6:34 
Generalsp_executesql Pin
SVb.net22-Feb-08 22:09
SVb.net22-Feb-08 22:09 
QuestionACCESS AND SQL HELP(A students question) Pin
ABQ4722-Feb-08 10:46
ABQ4722-Feb-08 10:46 
GeneralRe: ACCESS AND SQL HELP(A students question) Pin
pmarfleet22-Feb-08 10:58
pmarfleet22-Feb-08 10:58 
GeneralRe: ACCESS AND SQL HELP(A students question) Pin
Christian Graus22-Feb-08 11:15
protectorChristian Graus22-Feb-08 11:15 
GeneralRe: ACCESS AND SQL HELP(A students question) Pin
Paul Conrad25-Feb-08 8:51
professionalPaul Conrad25-Feb-08 8:51 

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.