.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Average delay between 2 sales (AdventureWorks)

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :Sql Server


In the Adventurework FactInterSales table, there's an "orderDateKey" key. 

Imagine that I want to add a new calculated measure, in order to be able to get the average delay (in days) between sales, in general or by customer...

How would you do that ? A new calculated member ? a script command ? Or do I have to do this with SSIS when importing the data ? I hope no...

I've been searching on the net, the DATEDIFF function seams to be the solution, but I couldn't make it work successfully

Thanks a lot for your help


View Complete Post

More Related Resource Links

Calculation of average sales


Hi everybody,


I am currently developing reports with Report Builder 2.0 and got stuck with the following:


In order to calculate an average sales amount, I did the following:


Dataset 1:


sql server 2008 adventureworks database


dear Friends

For my MCTS 70 -433 examination, I recently installed sql server 2008 and installed the sample databases too. but my issue is, in that book they have mentioned a database called "AdventureWorks2008" and the nice thing is I don't have a such a database with me in my sql server 2008. 

And the query is 

-- MERGE Statement
USE AdventureWorks2008
MERGE INTO	Sales.SalesOrderDetailHistory AS SODH
USING Sales.SalesOrderDetail AS SOD
ON SODH.SalesOrderID = SOD.SalesOrderID
AND SODH.SalesOrderDetailID = SOD.SalesOrderDetailID
INSERT (LineTotal, SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty
, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount
, rowguid, ModifiedDate, Cancelled)
VALUES(LineTotal, SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty
, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount
, rowguid, ModifiedDate, DEFAULT)
UPDATE SET SOHD.Cancelled = 'True'
OUTPUT $action , inserted.* ;	

Please help me to overcome this issue and let me know where can I download that database too.

Thanking you

happy Coding

Email enabld list delay on recieving emails


So the situation is, i have a list, that receives emails from a particular account all day long, recently it has started recieving emails "late" being it will mass process emails at various times of the day. Before it proccessed them as soon as they were received.

Event log shows

A critical error occurred while processing the incoming e-mail file C:\Inetpub\mailroot\Drop\e472144001cb44a40000001e.eml. The error was: The process cannot access the file 'C:\Inetpub\mailroot\Drop\e472144001cb44a40000001e.eml' because it is being used by another process..


Have this error everywhere.

        -Restarted SMTP

        -Restarted IIS

It seems SMTP is having issues but wanted to come here and get some insight.


-I havent changed anythign recently except new cable runs to the switch

-There is no mail in the (Drop, Mailbox,Pickup, Queue) folders

-mail setup settings are

              -incoming is set to "Advanced" , no,  server.domain.com

Outgoing is my exange server.



Timer delay

Hi guys, Please can one of you help me out. I have a bit of a trouble with the timer, it delay of 10 seconds which it should be of 5 seconds when I started the timer.   here it is the code Public Class Form1 Dim cPos As Point Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cPos = Windows.Forms.Cursor.Position End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Me.Panel1.ClientRectangle.Contains(Me.Panel1.PointToClient(Windows.Forms.Cursor.Position)) Then Me.Panel1.Show() If Panel1.Visible = True Then Timer1.Interval = 5000 Timer1.Start() Dim nPos As Point = Windows.Forms.Cursor.Position If cPos <> nPos Then cPos = nPos Else MessageBox.Show("mouse NOT moved in last 5 secs.") Panel1.Visible = False Timer2.Enabled = True End If End If End If End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Dim nPos As Point = Windows.Forms.Cursor.Position If cPos <> nPos Then cPos = nPos If Panel1.Visible = False Then If Me.Panel1.ClientRectangle.Contains(Me.Panel1.PointToClient(Windows.Forms.Cursor.Position)) Then Panel1.Visib

AdventureWorks and Visual Studio 2008

Would someone please tell me how to get Visual Studio to automatically create the correct SQL statements so that I can stop getting the following error:"there was an error executing the query. please check the syntax of the command and if present the types and values of the parameters and ensure they are correct. Invalid object name 'Product'" 'Product'  gets replaced with whatever table name I drag onto my web form from the server explorer. The only information that may help that I know is that I noticed that Visual Studio creates the following select statement: "SELECT * FROM [BillOfMaterials]" and this generates an error. Where as when I manually type "SELECT * from Production.BillOfMaterials;" Everything works fine. The only issue with this is i would hate to have to manually enter all of the SQL statement into my web app.  Any help would me great appreciate. SQL2008.AdventureWorks_All_Databases.x64 - this is the version of AdventureWorks that I downloaded and installed on my machine.

How to delay the close() in client

HI,        I'm writing a WCF using wsDualHttpBinding as binding property, in my client side i specified the closeTimeout as 00:00:00, it throws the timout exception, when i closed the channel, using close() in client side code.   However, if i specify the closeTimeout  as 00:00:01, it will finish the close of channel, within 1 second. But for 0.01, 0.1 second it cannot able to close, now i want to specify a 30 second closeTimeout, and in the code behind i want to make the close to take more time to finish closing the channel. How can i make the close() to wait,   any idea,

Invoke Delay Activity multiple times

HI! I am using Workflow Foundation workflows with sharepoint lists. I have a state machine workflow. One state of workflow has 2 event driven activities, one is waiting for task change and other is waiting for delay of 1 day. What i need is to send email if delay of 1 day is elapsed and send this email every day. But Delay activity is invoked only once. How can i change it so that it can be invoked multiple times. Shabih

Business explainfor tables and hierarchy in AdventureWorks database and REAL_Warehouse_Sample_V6 cub

AdventureWorks (ProductModel table, what is this table for) ------------------------------ REAL_Warehouse_Sample_V6 (Periodicity(only have one attribute:period)) (Replen Strategy(three level hierarchy(strategy type:backlist,frontlist);(strategy:Modeled,Buyer Managed,No replenishment,Store Managed)) Another one is what is the difference and relation between buyer and customer in cube REAL_Warehouse_Sample_V6? -------------------------------------------- I can not understand the business meaning behind these tables and architecture,can any one help explain the meaning for upper hierarchy and table? happyMan

Delay in Sequence Problem??????

I have a Approval work flow..What i am doing is,if the approver doesn't review with in a certain time-period the task will be send to another person in the company.... I did this by using Sharepoint List ..and i am using Listen Activity ... Inside the Listen Activity i am using HandleExternalEventActivity and Delayas Parellel Activity... But it does'nt work...I dont know how to extend it... I refers many article...most of them said there is an issue in delay activity...i got conduced ..is that problem fixed or not ? pls guide me... Thanks ________________________ arWINdh

For loop to find sum and average

I am trying to write a program that will use the for loop to find the sum, and average of 10 numbers a user enters. I was able to do something like this with out a for loop but I want something a bit more efficient . double num1; double num2; double num3; double num4; double num5; double num6; double num7; double num8; double num9; double num10; Console.Write("Please enter a number: "); num1 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num2 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num3 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num4 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num5 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num6 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num7 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num8 = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter a number: "); num9 = Convert.ToDouble(Console.ReadLine()); Conso

Forum Subscriptions emails are sent with a delay of 2 hours

Hello I have a couple of forum subscriptions like the ASP.NET MVC forum and I have noticed that when someone creates a new thread that it takes up to 2 hours before I receive the email notification. Can this setting be changed somewhere because I cannot find it in "Edit Profile". Thanks 

average of difference between rows

Hello, I need to calculate the difference between two rows and than find the average of those values. For example I have: date Value Value I need (difference between rows) 22.03.2010 50 30 24.01.2010 20 10 10.09.2009 10 NULL ----- 20 (which is the average of this column) Any suggestions? Thanx in advance :)

How to Show Loading Message while delay in Page Opening

Hy My web application is make time to open First page due to various data control on the page and values are coming to that control from database so i want to show the loading message of gif image during page loading delay. I have written this code in my master page but that image is not showing the application so please give solution on that problem<html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server">   <title>Load Wait Message Demo</title> </head> <script type="text/javascript" language="javascript">   if(document.getElementById) { // IE 5 and up, FF     var upLevel = true;   } else if(document.layers) { // Netscape 4     var ns4 = true;   }   else if(document.all) { //IE 4      var ie4 = true;   }   function showObject(obj) {   if(ns4) {      obj.visibility = "show";   }   else if (ie4 || upLevel) {      drawMessageBox(); obj.style.visibility = "visible";            } }        showObject('splashScreen');   function hideObject(obj) {   if(ns4) {     

Extremely long delay in MapUrlToZoneWrapper called by LateBoundBitmapDecoder.DownloadCallback

After a random interval, our application will appear to lock up when switching to a different view. The profiler indicates that the time is being spent in MS.Internal.SecurityHelper.MapUrlToZoneWrapper (and presumably therefore in the native MapUrlToZone function).  The method takes 1.3s to return; multiply by ~150 images and the total wait time for the user is three minutes (for what is usually an instant operation). My question is - why does this start happening at a random point during the application's lifetime?  For the first half-hour or so, the experience is perfectly normal - you can flip between the two views as much as you like with no ill effect.  Then at a certain point it starts taking minutes to switch - one CPU core is at 100% during the period. Internally, we're using bitmaps with a UriSource pointing to an in-process http server (long story about why this is the case).

Delay Activity wake up issue..

Hi guys! I've a big problem with my sharepoint 2010: when I use a DelayActivity my workflow NEVER wake up... Sharepoint timer service is ON, and it's loop time is set to 2 minutes. I have already tried with this suggestion (http://howtosharepoint.blogspot.com/2010/05/sharepoint-workflow-delay-activity-not.html), but I still have the problem. Any ideas? Enrico

SSRS 2008 Matrix - Cannot get average formula or growth formula to work

I have a report in Excel that I'm trying to replicate in SSRS 2008.  The report looks like this:   Priority 08/21/10 08/14/10 08/07/10 07/31/10 07/24/10 07/17/10 07/10/10 TOTAL Average Customer Name Code # of Lds # of Lds # of Lds # of Lds # of Lds # of Lds # of Lds  # of Lds   Check  #N/A            4            4            4            8            4            9           -            33          5       83%  A2             1          -            -            -            -            -           

Unit Testing Delay Activity in workflows 4.0

I need to run unit test scripts for workflows developed in workflows 4.0. I have requirement to unit test the whole workflow including the delay activity.   If the delay activity contains for example for 15 days delay and after that it perform certain other tasks. In this scenario I cannot wait for 15 days for unit test the workflows.   Please let me know How to unit test workflows in case of delay activity? Can I modify the pending timer filed in instance table to advance time?  rajeevkalyan
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend