Too little information. Or is the query so famous that I need to know it without showing?I have a query in which I want ...
SELECT Table1.FieldName,
[FieldName]/4 AS [First Quarter],
[FieldName]/4 AS [Second Quarter],
[FieldName]/4 AS [Third Quarter],
[FieldName]/4 AS [Fourth Quarter]
FROM Table1;
FieldName | First Quarter | Second Quarter | Third Quarter | Fourth Quarter |
---|---|---|---|---|
10 | 2.5 | 2.5 | 2.5 | 2.5 |
11 | 2.75 | 2.75 | 2.75 | 2.75 |
50 | 12.5 | 12.5 | 12.5 | 12.5 |
100 | 25 | 25 | 25 | 25 |
133 | 33.25 | 33.25 | 33.25 | 33.25 |
200 | 50 | 50 | 50 | 50 |
Too little information. Or is the query so famous that I need to know it without showing?
best guess - have 4 columns (Q1,Q2,Q3,Q4) with a calculation dividing the 100 by 4
after over 240 posts you should know by now the requirements for asking a question of this nature is to provide some context, some example data and the result required for that calculation.
SELECT qryAnnualPlan.CodeObject, qryAnnualPlan.ObjectType,Count(qryAnnualPlan.ObjectType) AS CountOfObject, tblCodeObject.Multiplicity
FROM qryAnnualPlan INNER JOIN tblCodeObject ON qryAnnualPlan.CodeObject = tblCodeObject.CodeObject
GROUP BY qryAnnualPlan.CodeObject, qryAnnualPlan.ObjectType, tblCodeObject.Multiplicity;
Select ...., CountOfObject * multiplicity / 4 as 1stQuarter, CountOfObject * multiplicity/ 4 a 2ndQuarter, ... from qryPlanCount
MajP, thank you for your help and your time.For ease I do it in two steps. Save that query above then do what I showed. So call your query
qryPlanCount
Code:Select ...., CountOfObject * multiplicity / 4 as 1stQuarter, CountOfObject * multiplicity/ 4 a 2ndQuarter, ... from qryPlanCount
Public Function GetQuarter(Val As Long, WhichQtr As Integer) As Double
Dim rtn As Double
Dim qtr As Long
Dim rmdr As Long
qtr = Val \ 4
rmdr = Val Mod 4
rtn = qtr
If WhichQtr > 0 And WhichQtr < 5 Then
If WhichQtr <= rmdr Then rtn = rtn + 1
End If
GetQuarter = rtn
End Function
I just wrote it like that without any particular intention.Why is column 2 18 and not the last column?