Click here to Skip to main content
15,900,461 members
Home / Discussions / Database
   

Database

 
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 
AnswerRe: dynamically change column name Pin
Simon_Whale25-Mar-11 1:31
Simon_Whale25-Mar-11 1:31 
AnswerRe: dynamically change column name Pin
Eddy Vluggen25-Mar-11 1:32
professionalEddy Vluggen25-Mar-11 1:32 
GeneralRe: dynamically change column name Pin
PIEBALDconsult25-Mar-11 3:03
mvePIEBALDconsult25-Mar-11 3:03 
GeneralRe: dynamically change column name Pin
Eddy Vluggen25-Mar-11 5:22
professionalEddy Vluggen25-Mar-11 5:22 
GeneralRe: dynamically change column name Pin
PIEBALDconsult25-Mar-11 16:00
mvePIEBALDconsult25-Mar-11 16:00 
GeneralRe: dynamically change column name Pin
Eddy Vluggen26-Mar-11 1:52
professionalEddy Vluggen26-Mar-11 1:52 
GeneralRe: dynamically change column name Pin
jschell25-Mar-11 8:29
jschell25-Mar-11 8:29 
GeneralRe: dynamically change column name Pin
PIEBALDconsult25-Mar-11 16:16
mvePIEBALDconsult25-Mar-11 16:16 
GeneralRe: dynamically change column name Pin
Eddy Vluggen26-Mar-11 2:04
professionalEddy Vluggen26-Mar-11 2:04 
GeneralRe: dynamically change column name Pin
jschell26-Mar-11 6:08
jschell26-Mar-11 6:08 
GeneralRe: dynamically change column name Pin
Wendelius26-Mar-11 3:38
mentorWendelius26-Mar-11 3:38 
QuestionHow to calculate average of qty sold the last 6 months or less Pin
Joe Smith IX23-Mar-11 23:50
Joe Smith IX23-Mar-11 23:50 
Table [Sold]

ID PID Qty Date
-- --- --- ---------
1  1   8   jun 1, 2010
2  3   5   jul 1, 2010
3  3   2   aug 1, 2010
4  1   1   sep 1, 2010
5  3   4   sep 30, 2010
6  2   3   oct 8, 2011
7  2   5   nov 1, 2011
8  3   2   dec 1, 2011
9  1   8   jan 1, 2011
10 2   5   feb 1, 2011

Hi all,

I have difficulty composing a rather complex (for me) query. I would like to know the average qty sold of each PID per day based on the last 6-month data. If data is less than 6 month, then adjust accordingly.

So on the data above:
Today: Mar 24, 2011
6-month cut-off: Sep 24, 2010
I want to get:
PID Qty/day
--- -------
1   8/182       = 0.0440
2   (3+5+5)/168 = 0.0774 -> 168: because the oldest sale is oct 8
3   (4+2)/182   = 0.0330


Is there any way I can do this? Somebody help me, please? Thanks in advance.
AnswerRe: How to calculate average of qty sold the last 6 months or less [modified] Pin
Chris Meech24-Mar-11 2:52
Chris Meech24-Mar-11 2:52 
GeneralRe: How to calculate average of qty sold the last 6 months or less Pin
Joe Smith IX24-Mar-11 18:10
Joe Smith IX24-Mar-11 18:10 
GeneralRe: How to calculate average of qty sold the last 6 months or less Pin
Klaus-Werner Konrad25-Mar-11 7:11
Klaus-Werner Konrad25-Mar-11 7:11 

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.