MSAS: Trimmed Average
May 5, 2006
Hi,
I have the following table:
OrderNumber varchar(15)
Completed int(1)
Certificate int(1)
ThroughputTime int(4)
With the following data:
OrderNumber Completed Certificate ThroughputTime
00001 1 1 1
00002 1 1 2
00003 1 0 1
00004 1 0 1
00005 0 1 2
00006 0 1 1
00007 0 0 4
00008 0 0 89
I have a dimension:
All Completed
- Completed
- Not Completed
and a dimension:
All Certificate
- No Certificate
- Certificate
I also have measures:
TptSum which Sums ThroughputTime
TptCount which Counts OrderNumbers
TptAvg which divides TptSum by TptCount
My problem is with the next measure:
In MSAS I created a Cube which shows the measures on the columns and both Completed and Certificate on the rows. The OrderNumber selection is set to "All Ordernumbers". The measures as listed above are displayed exactly as I expect them to do. TptSum gives the sum for the subselection showed on the left. TptCount and TptAvg also show the expected values on their distinct rows.
I can't upload a screenshot but it looks like this:
TptSum TptCount TptAvg
All Certificate All Completed 101 8 12.63
Completed 5 4 1.25
Not Completed 96 4 24.00
No Certificate All Completed 95 4 23.75
Completed 2 2 1.00
Not Completed 93 2 46.50
Certificate All Completed 6 4 1.50
Completed 3 2 1.50
Not Completed 3 2 1.50
So far so good. Each datarow only takes the records that match the criteria at the left.
Now however, To exclude exceptions that have a huge impact on the average I want to create a trimmed average. That is, I want to exclude the top 25% values in my trimmed average measure, which are the 2 records with the highest ThroughputTime, being ordernumber 00007 and 00008 in the "All Certificate" & "All Completed" row, but different in the other rows. I also want the bottom 25% values to be trimmed, which are the 2 records with the lowest ThroughputTime, being ordernumber 00001 and 0003 in the "All Certificate" & "All Completed" row.
I tried a lot of things, but i can't get it working. Somehow all my statements don't take the subselections on the rows into account. Really frustrating.
What I want to achieve is the following:
TptSum TptCount TptAvg TrimmedAvg
All Certificate All Completed 101 8 12.63 1.50 ((2+1+2+1) / 4) (middle 4 records)
Completed 5 4 1.25 1.00 ((1+1) / 2) (middle 2 records)
Not Completed 96 4 24.00 3.00 ((2+4) / 2) (middle 2 records)
No Certificate All Completed 95 4 23.75 2.50 ((1+4) / 2) (middle 2 records)
Completed 2 2 1.00 1.00 ((1+1) / 2) (all 2 records)
Not Completed 93 2 46.50 46.50 ((4+89) / 2) (all 2 records)
Certificate All Completed 6 4 1.50 1.50 ((1+2) / 2) (middle 2 records)
Completed 3 2 1.50 1.50 ((1+2) / 2) (all 2 records)
Not Completed 3 2 1.50 1.50 ((1+2) / 2) (all 2 records)
I hope I describe my problem well... I also hope someone knows a solution. I can also post the things I tried, but I'm afraid that makes it more confusing, because nothing worked ;)
Thanks,
Edward
PS. newbie alert! :beer:
View 1 Replies
ADVERTISEMENT
May 5, 2006
Hi,
I have the following table:
OrderNumber varchar(15)
Completed int(1)
Certificate int(1)
ThroughputTime int(4)
With the following data:
OrderNumber Completed Certificate ThroughputTime
00001 1 1 1
00002 1 1 2
00003 1 0 1
00004 1 0 1
00005 0 1 2
00006 0 1 1
00007 0 0 4
00008 0 0 89
I have a dimension:
All Completed
- Completed
- Not Completed
and a dimension:
All Certificate
- No Certificate
- Certificate
I also have a measures:
TptSum which Sums ThroughputTime
TptCount which Counts OrderNumbers
TptAvg which divided TptSum by TptCount
My problem is with the next measure:
In MSAS I created a Cube which shows the measures on the columns and both Completed and Certificate on the rows. The OrderNumber selection is set to "All Ordernumbers". The measures a listed above are displayed exactly as i expect them to do. TptSum gives the sum for the subselection showed on the left. TptCount and TptAvg also show the expected values on their distinct rows.
I can't upload a screenshot but it looks like this:
TptSum TptCount TptAvg
All Certificate All Completed 101 8 12.63
Completed 5 4 1.25
Not Completed 96 4 24.00
No Certificate All Completed 95 4 23.75
Completed 2 2 1.00
Not Completed 93 2 46.50
Certificate All Completed 6 4 1.50
Completed 3 2 1.50
Not Completed 3 2 1.50
So far so good. Each datarow only takes the records that match the criteria at the left.
Now however, To exclude exceptions that have a huge impact on the average I want to create a trimmed average. That is, I want to exclude the top 25% values in my trimmed average measure, which are the 2 records with the highest ThroughputTime, being ordernumber 00007 and 00008 in the "All Certificate" & "All Completed" row, but different in the other rows. I also want the bottom 25% values to be trimmed, which are the 2 records with the lowest ThroughputTime, being ordernumber 00001 and 0003 in the "All Certificate" & "All Completed" row.
I tried a lot of things, but i can't get it working. Somehow all my statements don't take the subselections on the rows into account. Really frustrating.
What I want to achieve is the following:
TptSum TptCount TptAvg TrimmedAvg
All Certificate All Completed 101 8 12.63 1.50 ((2+1+2+1) / 4) (middle 4 records)
Completed 5 4 1.25 1.00 ((1+1) / 2) (middle 2 records)
Not Completed 96 4 24.00 3.00 ((2+4) / 2) (middle 2 records)
No Certificate All Completed 95 4 23.75 2.50 ((1+4) / 2) (middle 2 records)
Completed 2 2 1.00 1.00 ((1+1) / 2) (all 2 records)
Not Completed 93 2 46.50 46.50 ((4+89) / 2) (all 2 records)
Certificate All Completed 6 4 1.50 1.50 ((1+2) / 2) (middle 2 records)
Completed 3 2 1.50 1.50 ((1+2) / 2) (all 2 records)
Not Completed 3 2 1.50 1.50 ((1+2) / 2) (all 2 records)
I hope I describe my problem well... I also hope someone knows a solution. I can also post the things I tried, but I'm afraid that makes it more confusing, because nothing worked ;)
Thanks,
Edward
View 1 Replies
View Related
Apr 12, 2008
Hi
I have an outcome of my query a string value with 20 characters, e.g. A/P Payments - P00ST. I want to get a trimmed outcome like P00ST, that is trimmed by 15 characters. How to write a query for this?
Regards
View 3 Replies
View Related
Apr 25, 2007
I am reposting this from the VB IDE forum, becaue I received no response
Using VS05 SP1 Pro/SQL Express...
There are two tables, UserIDs and Recordings (which has a foreign key relating it back to UserIDs).
I created a Stored Procedure via Server Explorer that returns the user ID for a given Foreign Key in Recordings table. If the UserID is "0001", then "0001" is return (userIDs are stored as strings). The stored procedure works every time.
I then created a table adpater that uses the above stored procedure. The table adapter is used in code. It has always worked fine, but i have discovered if the user ID starts with 0, those zeros are trimmed by the table adapter .
For example:
UserID = Me.TableAdapter_Recordings.FillBy_StoredProceedure_Return_UserID(ForeignKey_Recordings_Table).ToString
should result in a userID of "0001", but instead results in "1", which, from a string view point, is incorrect. As strings, "0001" and "1" are totally different, and the "1" fails when you do a fill for the table UserIDs.
So, the Stored Procedure and the Table Adapter using the same Stored Procedure return different results, with the Table Adapter being wrong. Why is it trimming the zeros? Is there anyway to stop that so the results are correct?
Thanks!
Bob
View 1 Replies
View Related
Nov 4, 2015
The method I need is TRIMMED MEAN as I need to exclude outliers from an average in the same way as described here:
[URL
I have searched and it appears that Excel has a built-in function for this but DAX does not. What is the best way to do this in PowerPivot?
View 3 Replies
View Related
Jun 21, 2015
Calculation of an average using DAX' AVERAGE and AVERAGEX.This is the manual calculation in DW, using SQL.In the tabular project (we're i've noticed that these 4 %'s are in itself strange), in a 1st moment i've noticed that i would have to divide by 100 to get the same values as in the DW, so i've used AVERAGEX:
Avg_AMP:=AVERAGEX('Fct Sales';'Fct Sales'[_AMP]/100)
Avg_AMPdollar:=AVERAGEX('Fct Sales';'Fct Sales'[_AMPdollar]/100)
Avg_FMP:=AVERAGEX('Fct Sales';'Fct Sales'[_FMP]/100)
Avg_FMPdollar:=AVERAGEX('Fct Sales';'Fct Sales'[_FMPdollar]/100)
The results were, respectively: 701,68; 2120,60...; -669,441; and finally **-694,74** for Avg_FMPdollar.i can't understand the difference to SQL calculation, since calculations are similar to the other ones. After that i've tried:
test:=SUM([_FMPdollar])/countrows('Fct Sales') AND the value was EQUAL to SQL: -672,17
test2:=AVERAGE('Fct Sales'[_Frontend Margin Percent ACY]), and here, without dividing by 100 in the end, -696,74...
So, AVERAGE and AVERAGEX have a diferent behaviour from the SUM divided by COUNTROWS, and even more strange, test2 doesn't need the division by 100 to be similar to AVERAGEX result.
I even calculated the number of blanks and number of zeros on each column, could it be a difference on the denominator (so, a division by a diferente number of rows), but they are equal on each row.
View 2 Replies
View Related
Feb 25, 2008
Dear all,
I am trying to connect Cognos to MSAS 2005 from an UNIX server (AIX). I am getting the following error:
QFS-ERR-0002 Unable to find or load the shared library '/cognos/c8/./bin/libykodp.so' (or one of its dependents) containing the provider 'MSAnalysis2005ODP'.
Is this file libykodp.so part of a SQL Server shared library (.o file) that must be installed on the UNIX server? Any pointers? Many thanks.
Best regards,
Pedro Martins
View 3 Replies
View Related
Dec 12, 2005
Hi friends,
I am new to MSAS world. I need help related to this. I want to pull data from MSAS cube programmatically. Only way I know is thru ODBO, but that won't help me in this case, cause I might have to drill down upto all possible intersections stored in MSAS (at least all of the stored members). Doing this thru MDX could be humongous thing, at least manipulating data taken out using ODBO.
I might be missing something out here. Can anybody help. It would also help if somebody can tell me if any other approach is poosible.
Thank you.
Abhijeet
View 3 Replies
View Related
Dec 14, 2005
Client have 2 servers, one with Sqlserver 2000 and one with Analysis Services.
Want to add a "Analysis Services Processing Task" to my DTS job on the SQLserver but the task does not exist since MSAS is not installed on the SQLserver...
Client does not want to install MSAS on the SQL Server....
Any ideas how to setup auto processing of the cubes ???
Regards Tale Liereng
View 3 Replies
View Related
Feb 15, 2008
I have a temp_max column and a temp_min column with data for every day for 60 years. I want the average temp for jan of yr1 through yr60, averaged...
I.E. the avg temp for Jan of yr1 is 20 and the avg temp for Jan of yr2 is 30, then the overall average is 25.
The complexity lies within calculating a daily average by month, THEN a yearly average by month, in one statement.
?confused?
Here's the original query.
accept platformId CHAR format a6 prompt 'Enter Platform Id (capital letters in ''): '
SELECT name, country_cd from weather_station where platformId=&&platformId;
SELECT to_char(datetime,'MM') as MO, max(temp_max) as max_T, round(avg((temp_max+temp_min)/2),2) as avg_T, min(temp_min) as min_temTp, count(unique(to_char(datetime, 'yyyy'))) as TOTAL_YEARS
FROM daily
WHERE platformId=&&platformId and platformId = platformId and platformId = platformId and datetime=datetime and datetime=datetime
GROUP BY to_char(datetime,'MM')
ORDER BY to_char(datetime,'MM');
with a result of:
NAME_________________CO
-------------------- --
OFFUTT AFB___________US
MO______MAX_T _____AVG_T__MIN_TEMTP_TOTAL_YEARS
-- ---------- ---------- ---------- -----------
01_________21______-5.31________-30__________60
02_________26______-2.19______-28.3__________61
03_______31.1_______3.61______-26.1__________60
04_______35.6______11.07______-12.2__________60
05_______37.2_______17.2_______-3.3__________60
06_______41.1______22.44__________5__________60
07_______43.3______24.92________7.2__________60
08_______40.6______23.71________5.6__________60
09_________40______18.84_______-2.2__________59
10_______34.4_______12.5_______-8.9__________59
11_________29_______4.13______-23.9__________60
12_________21______-2.52______-28.3__________60
View 4 Replies
View Related
May 5, 2005
I am a Cognos developer (10 years) and am frustrated with the apparent lack of MSAS ability to replicate Cognos measure scope / allocation features.
I have built three cubes, Sales Info, Store Count, and Date Count and wrapped these into a virtual cube (Sales Reporting). Both the Store Count and Date Count cubes have just a single dimension and a single measure each (Distinct counts of Stores and of Days respectively), this is my attempt at replicating the use of several fact queries with differing scope in Cognos Transformer. In my virtual cube I wish the distinct counts to be allocated constantly within dimensions that are out of scope. For instance if I have product categories as rows and my measures as columns then I wish to see the total number of stores on each row and the number of days in the date range so that I can calculate a few ratio's. I do not wish to see the number of stores that sold products in each category or the number of days products in that category were sold, which is what I see if I use distinct count measures in a cube with the exact same dimensionality.
All that I have been able to achieve is something similar to Cognos's 'do not allocate', zero's appear down the list of categories in out of scope dimensions.
TIA
View 4 Replies
View Related
Jul 30, 2015
We are experiencing authentication/ Kerberos issues after a password for the MSA's has changed. We use MSA for our SQL 2012 and windows 2012 combination Servers. This errors creates issues while backing up and Service Broker connectivity.We had to restart sql services to fix it, but this not seem to be a resolution for me because the next time the password changes on these MSA's we may have to restart sql services.There seems to be a known issue for windows 2008 R2 servers and fix is available and we incorporated it. But the issue we are facing is on windows 2012 Server.
View 3 Replies
View Related
May 5, 2005
Good day all
I am unable to crosstab different alternate hierarchies of an MSAS cube from a single dimension, I'm using Cognos Powerplay (7.3 web and client) to browse the data. v 7.1 displays the same behaviour.
When I try to create the crosstab the display replaces both rows and columns to the alternate path, it overwrites the original path. Can anyone tell me if this is a Cognos issue or an Analysis services one and if there is any way around it. The only solution I have at the moment is to bodge it by creating seperate dimensions for each alternate hierarchy however this is ugly and difficult to use.
Regards
Mike
View 7 Replies
View Related
Sep 26, 2007
Hello,I have two tables:[Posts] > PostId, ...[Ratings] > RatingId, PostId, RatingI want to select all posts and add a new column named AverageRating.This new column is the average of all ratings associated to that Post.If a post was not rated then its AverageRating would be NULL.How can I do this?Thanks,Miguel
View 2 Replies
View Related
Apr 18, 2006
if I have a bunch of times, and want an average of them, how do I do that?
Thanks.
For more details, see this thread:
http://www.dbforums.com/showthread.php?t=1215633
View 8 Replies
View Related
Jun 19, 2007
I am getting the number of transactions for two different months based on dates entered from the user. I need to display the number of transactions along with the average sale. I have figured out how to get the dates and sum the transactions but I can't seem to add in the average....
(@prevMonthStart datetime, @prevMonthEnd datetime, @thisMonthStart datetime, @thisMonthEnd datetime)
as
select sum(case when orders.orderdate between @prevMonthStart and @prevMonthEnd then 1 else 0 end ) as PrevMonthCount,
sum(case when orders.orderdate between @thisMonthStart and @thisMonthEnd then 1 else 0 end ) as ThisMonthCount
(how do I add in the average for both months? The column is orders.ordertotal)
View 3 Replies
View Related
Jan 6, 2008
Using MS SQL 2005 server how can I get the average cost price of item 'shirt' from this table please?
code item description cost retail
---- ---- ----------- ---- ------
191 shirt shirt - white 2.30 9.99
170 pants pants - beige 6.34 15.00
196 shirt shirt - red 2.64 9.99
199 shirt shirt - blue 2.61 9.99
View 2 Replies
View Related
Jan 19, 2008
Hi !
I am having this problem. I have a grouping someting like this.
Group1
Resolved Resolution Time Average Resolution Time
30 2904.46 96.82
54 1442.03 26.70
0 0.00 0.00
0 0.00 0.00
------------------------------
Avg : 30.88
Now to calculate the average inside the grouping I have used this
iif(Sum(Fields!ResolutionTime.Value) = 0 ,"0.00",(Sum(Fields!ResolutionTime.Value)/(iif(Count(Fields!ResolvedDate.Value)=0,1,Count(Fields!ResolvedDate.Value)))))
I am at a loss how to calculate the group footer (Result = 30.88 ) which is equal to (96.82 + 26.70 + 0 + 0 ) / 4 . This is the result from the existing Crystal report. I am trying to convert this report to reporting services. Now I cannot nest aggregate functions and also the row number can be dynamic I am confused how to resolve it.
Any ideas will be greatly appreciated.
Thanks in advance.
--Abbi.
View 9 Replies
View Related
May 21, 2008
Hi All,
I was hoping someone could help me with pluging moving average into my report.
This is the template I am using for moving average:
//
/*Returns the average value of a member over a specified time interval.*/
CREATE MEMBER CURRENTCUBE.[MEASURES].[Moving Average]
AS Avg
(
[<<Target Dimension>>].[<<Target Hierarchy>>].CurrentMember.Lag(<<Periods to Lag>>) :
[<<Target Dimension>>].[<<Target Hierarchy>>].CurrentMember,
[Measures].[<<Target Measure>>]
)
// This calculation returns the average value of a member over the specified time interval.
FORMAT_STRING = "Standard";
This is what I have before I started to add the moving average. The report works but only displays the cummulative complexity rank.
WITH
MEMBER [Measures].[Date Key] AS
[Date].[Date].CurrentMember.UniqueName
SELECT
{
[Measures].[Date Key],
[Measures].[ComplexityRank]
} ON COLUMNS,
(
[Work Item].[System_State].[System_State],
(StrToMember(@StartDateParam):StrToMember(@EndDateParam))
)
ON ROWS
FROM [Team System]
WHERE
(
STRTOMEMBER("[Team Project].[Team Project].["+@Project+"]"),
STRTOSET(@IterationParam),
STRTOSET(@AreaParam),
STRTOSET(@WorkItemTypeParam)
)
What I want to do is also add the moving average for this over the parameter of Iterations. (IterationParam). This is what I have so far with the moving average in my report: I know I must have a lot of errors but I can't get past this first error. I highlighted the line with error. The error said: Query(7, 15) Parser: The syntax for '.' is incorrect. (msmgdsrv)
WITH
MEMBER
[Measures].[Date Key] AS
[Date].[Date].CurrentMember.UniqueName,
[Measures].[Moving Average] as
AVG({[Date].[Date].currentmember.lag(@IterationParam):
[Date].[Date].currentmember},[Measures].[ComplexityRank])
SELECT
{
{measures.[moving average],measures.[Internet Total Product Cost]} on 0,
[Date].[Date]. Members
[Measures].[Date Key],
[Measures].[ComplexityRank]
} ON COLUMNS,
(
[Work Item].[System_State].[System_State],
(StrToMember(@StartDateParam):StrToMember(@EndDateParam))
)
ON ROWS
FROM [Team System]
WHERE
(
STRTOMEMBER("[Team Project].[Team Project].["+@Project+"]"),
STRTOSET(@IterationParam),
STRTOSET(@AreaParam),
STRTOSET(@WorkItemTypeParam)
Does anyone have any suggestions?
Thanks,
Nici
View 11 Replies
View Related
Jan 5, 2007
I have two tables, table a holds all the votes by users of each element in table b. I was wondering, how do I get the average of all those votes in table a that relate to that each instance of a element in table b. For example table b has two elements created by a certain user that has been voted 5 times each by users with scores like 2, 5, 4, 2 , 2 for both of them. I just need to get the average of those numbers that pertain to those elements in table b. Thanks for any help.
View 4 Replies
View Related
Oct 25, 2000
Can any one be able to help me to write a querry on Moving Average
Example
Product Volume
Fish
View 2 Replies
View Related
Sep 21, 2007
Hello all!This might be a newbie question, and there might be something Im just not thinking of right now, but I have a set of values that I need to get the average of but only from the middle 90%. Example:11 <-From here1234456 <- To here.7I thought I could solve it by subqueries and do the following:Select (((Select sum top 5 order asc) + (Select sum top 5 order desc)) - sum total)/rows*0.9 which would give me what I want, but I realised that when aggregating I cant order the subqueries.This is for an application (that will run the query on a sql-server) that only takes one query (although subqueries should be fine), and thats why I have a problem, I cant build any views or things like that.I guess my question is very simple: How can I get a sum of the bottom 5 percent without sorting descending?
View 9 Replies
View Related
May 8, 2012
Select * from personnel
where salary > ALL (SELECT AVG (salary) from personnel group by bolno)
And how i find max average salary?
View 8 Replies
View Related
Apr 9, 2008
Hi, I have two tables, Weekly and AverageEngTime. Weekly table has 14 columns, "Mon_Day,Mon_Night,Tue_day,....Sun_Night". AverageEngTime table has 15 columns, "Shifts,Mon_Day,Mon_Night,Tue_day,....Sun_Night". I have inserted "Average" as a value for column "Shifts" in AverageEngTime table. Now how do I find the average for each column in Weekly table and insert into AverageEngTime table in the respective columns, and in the row where Shifts = "Average".
I used the following codes to try but i receive errors at where statement.Please correct me. The expected output as below.
Shifts | Mon_day | Mon_Night | Tue_Day.....
Average | 5.2 | 10.2 | 15.2........
The codes that i tried..
declare @Weekday tinyint, @hour int
select @Weekday = datepart(dw,getdate()),@hour= datepart(hh,getdate())
if (@Weekday= 1 and (@hour>= 7 AND @hour<19))
begin
Insert Into AverageEngTime(Sat_Night) where Shifts = 'Average'
SELECT AVG(Sat_Night)
FROM Weekly
end
if ((@Weekday= 1 and @hour >= 19) OR (@Weekday = 2 and @hour < 7))
begin
Insert Into AverageEngTime(Sun_Day) where Shifts = 'Average'
SELECT AVG(Sun_Day)
FROM Weekly
end
View 7 Replies
View Related
May 28, 2008
Problem
fldyear fldascending flddecending
2007 20 23
2006 21 14
2007 41 12
2007 12 5
how do i find the average of fld ascending and descending where year=2007
Your help will be appreciated
View 6 Replies
View Related
Jul 12, 2013
How do you get the average number in sql?
View 11 Replies
View Related
May 22, 2006
Can anyone tell me how to calculate a moving average for the below table?
--------------------
MONS /vol /counter(the date)
jan/8 / 2006-01-01
feb/9 / etc.
........
oct/5 / etc.
nov/6 /
dec/7 /
--------------------- I am using the below code, but it is having no effect......
SELECT i1.MONS, i1.COUNTER,
( SELECT AVG( i2.VOL )
FROM #RES1 AS i2
WHERE i2.MONS = i1.MONS And
DATEDIFF( month , i2.COUNTER , i1.COUNTER ) Between 0 And 12
) AS MovingAverageOver12Months
FROM #RES1 AS i1
ORDER BY i1.COUNTER
thanks in advance, dirwin
View 2 Replies
View Related
Feb 22, 2007
I made a code to in SQL reporting services for the reports of our company regarding the new applicants. Now I need to get the average datedifference in each phase from all applicants who entered Initial/Data Collection. Example, "Initial/Data collection"PHASE will have an average of 60 minutes to be finished, averaged from all 200 applicants, and "Screening"PHASE 240 minutes to be finished, averaged from 100 applicants.
All applicants must go through stage 1 before he can go to stage 2 and so on.
The date diff will be obtained from the "createdon" column subtracted to the last "modifiedon" column in each phase.
I need to insert that code to the existing code that I have if it is possible(which my boss prefer); or either if i can manipulate it in SQL reporting services in visual studio 2005.
Here is a sample output that I have.Each phase has a different color.
Here is the code that i used
SELECT subject, regardingobjectidname, createdon, modifiedon, stat, phase, initial,
(CASEphaseWHEN 'Initial/Data Collection' THEN 1
WHEN 'Screening' THEN 2
WHEN 'Assesment and Selection' THEN 3
WHEN 'Placement' THEN 4
END) AS Phasesort
FROM(
SELECT subject, regardingobjectidname, createdon, modifiedon, stat, initial,
(CASEstatWHEN 'Application Recieved' THEN 'Initial/Data Collection'
WHEN 'For Screening' THEN 'Screening'
WHEN 'Shortlisted' THEN 'Screening'
WHEN 'For Assesment' THEN 'Assesment and Selection'
WHEN 'For Assesment' THEN 'Assesment and Selection'
WHEN 'Passed Initial Interview' THEN 'Assesment and Selection'
WHEN 'Passed Profiles Assesment' THEN 'Assesment and Selection'
WHEN 'Passed Technical Exam' THEN 'Assesment and Selection'
WHEN 'For Placement' THEN 'Placement'
END) AS phase
FROM(
SELECT subject, regardingobjectidname, createdon, modifiedon, initial,
(CASEinitialWHEN '1 stage' THEN 'Application Recieved'
WHEN '2 stage' THEN 'Application Recieved'
WHEN '3 stage' THEN 'For Screening'
WHEN '4 stage' THEN 'Shortlisted'
WHEN '5 stage' THEN 'For Assesment'
WHEN '6 stage' THEN 'Passed Initial Interview'
WHEN '7 stage' THEN 'Passed Profiles Assesment'
WHEN '8 stage' THEN 'Passed Technical Exam'
WHEN '9 stage' THEN 'For Placement'
WHEN '10 stage' THEN 'For Placement'
END) AS stat
FROM(
SELECT subject, regardingobjectidname, createdon, modifiedon,
(CASEsubjectWHEN N'application received' THEN '1 stage'
WHEN 'process application' THEN '2 stage'
WHEN 'screen application' THEN '3 stage'
WHEN 'Phone interview' THEN '4 stage'
WHEN N'initial interview' THEN '5 stage'
WHEN 'profiles assessment' THEN '6 stage'
WHEN 'technical exam and interview' THEN '7 stage'
WHEN 'background and reference check' THEN '8 stage'
WHEN 'Job Offer' THEN '9 stage'
WHEN 'Contract Signing' THEN '10 stage'
END) AS initial
FROM(SELECT subject, regardingobjectidname, createdon, modifiedon
FROMFilteredTask
WHERE (subject IN ('application received', 'process application',
'screen application', 'initial interview', 'profiles assessment',
'technical exam and interview', 'background and reference check', 'job offer',
'contract signing'))
UNION ALL
SELECT subject, regardingobjectidname, createdon, modifiedon
FROMFilteredPhoneCall
WHEREsubject = 'phone interview'
) AS Orion
) AS Initials
) AS Phases
) AS Stats
ORDER BY regardingobjectidname, initial
I appreciate your help.
Thanks a lot.
__________________________________________________
Your future is made by the things you are presently doing.
Andrew
View 9 Replies
View Related
Mar 31, 2008
Here's my sample formula:
SELECT dbo.TechphonesCalibQA.ID, dbo.TechphonesCalibQA.EmpID, dbo.TechphonesCalibQA.EmpName, dbo.TechphonesCalibQA.[Level],
CASE dbo.TechphonesCalibQA.G_Branded WHEN dbo.TechphonesCalibClient.G_Branded THEN 1 ELSE 0 END AS G_Branded
FROM dbo.TechPhonesCalibClient INNER JOIN
dbo.TechphonesCalibQA ON dbo.TechPhonesCalibClient.SesID = dbo.TechphonesCalibQA.SesID
I would like to get the average of column G_branded (Result from the above formula) Any idea?
Thanks
View 3 Replies
View Related
Aug 17, 2006
Apologies for the simplicity of the question, but it reflects mycapabilities! I have the following sample fields coming from differenttables:LocationTimeDate (timestamp)DataI need to return the average of Data per Location per HOUR.Thanks.
View 7 Replies
View Related
Jul 20, 2005
Hi AllWe have an order processing database which includes the standard OrderHeader/Order Lines tables. I'm trying to write a query to get the averagenumber of lines per order over a given period, and I'm stuck :-(I can get the number of lines per order with:SELECT COUNT(*) FROM OrderDetailsINNER JOIN Order Header ONOrderHeader.OrderNo = OrderDetails.OrderNoWHERE OrderHeader.OrderDate ..... {various criteria} ...GROUP BY OrderDetails.OrderNumberBut how do I then get an average of this for the period?TIAMike Bannon
View 5 Replies
View Related
Dec 12, 2007
Hello Sql Expert!
I am trying to create a query that i can use to find the Average Check for transactions sold with a particular product.
The sql table i'm working with looks like this
ORDERID PRODUCT PRICE COUNT PAID
00001 burger 1.00 1 1.00
00001 hotdog 2.00 2 4.00
00001 drink 1.00 1 1.00
00001 shake 2.00 1 2.00
00002 burger 1.00 2 2.00
00002 shake 2.00 5 10.00
00003 hotdog 2.00 1 2.00
I would like to create something that will give me the average check for every product
ex
PRODUCT AVG CHECK
burger 10
shake 10
hotdog 5
drink 8
I created a query that could give me the % of each product that are ordered alone. I tried modifying it to give me avg check but ran into problems because the when i use max(product) to aggergate the field, it uses the products with the highest first character in the alphabet thus it products with V's and Y's get a lot more results (
Is there an easy way to do this by creating a temp table or nested query?
I can create a nested query to give me the average check for only one product at a time. I'm looking for something that can group the average check by all product.
Any help would be greatly appreciated!
Thank you so much!
View 1 Replies
View Related
Oct 9, 2007
time_stamp met_id ch1avg
12/7/2006 12:00:00 AM 0970 .5
12/7/2006 12:10:00 AM 0970 1.10
I have a table which collects data at 10 minute intervals, so per day, per met_id there are 144 records. Averaging ch1avg based on a single date query correctly produces 144 records. I am trying produce 144 record average based on any date spread in the where clasue. For example if the where is time_stamp between '01/01/2007' and '01/03/2007' this would be 288 records however the ouput needs to always be grouped into 144 records maximum. Looking for any assistance.
View 3 Replies
View Related