Viewing 15 posts - 8,851 through 8,865 (of 15,381 total)
Didn't you post something just like this a day or two ago? I know I saw some other thread trying to do this exact same thing. I can't however find...
March 29, 2013 at 12:58 pm
Not to sound unhelpful this has been solved thousands of times all over the internet. A quick google search brought me right to this site even. It all depends on...
March 29, 2013 at 12:57 pm
Thanks having ddl and data makes this a lot easier to deal with. I think you want something like this.
;with MyNewAverage as
(
select Action, Duration, Curr_date, DATEPART(hour, Curr_date) as HourOfDay, AVG(Duration)/1000...
March 29, 2013 at 12:22 pm
Hi and welcome to SSC. It is really difficult to offer any assistance without something to work with. By that I mean it would be far better if you could...
March 29, 2013 at 12:14 pm
If I add an identity to your table variable this works.
Declare @temp Table
(
MyKey int identity,
MyProc INT,
MySeq INT,
MyType VARCHAR(2),
MyTask VARCHAR(20)
)
INSERT INTO @TEMP
SELECT '1','1','a1','this is ' UNION ALL
SELECT '1','2','b2','supposed ' UNION...
March 29, 2013 at 10:31 am
Actually my code doesn't work because you don't have anything you can use to sort with. There appears to be nothing you can use as a primary key or even...
March 29, 2013 at 10:28 am
This works for your sample data. I changed the column names because dealing with reserved words as column names drives me nutty. 😉
Declare @temp Table
(
MyProc INT,
MySeq INT,
MyType VARCHAR(2),
MyTask VARCHAR(20)
)
INSERT...
March 29, 2013 at 10:25 am
Please don't post duplicate threads. The answer that Lowell gave you in the other thread is exactly the way to do this.
Please direct all replies here. http://www.sqlservercentral.com/Forums/Topic1436978-391-1.aspx
March 29, 2013 at 10:08 am
Ken Davis (3/29/2013)
March 29, 2013 at 9:45 am
ScottPletcher (3/29/2013)
SELECT Curr_date, Action, AVG(Duration)/1000 as Avg_Duration
FROM Table_1
WHERE Curr_date = CAST(GETDATE() as DATE)
GROUP BY...
March 29, 2013 at 9:24 am
Ken Davis (3/29/2013)
Starting a sql statement with WITH is new to me. I will have to look into that closer but it...
March 29, 2013 at 8:09 am
balasach82 (3/29/2013)
SELECT * from TABLENAME where isdate(ColA)=1 and (ColA)<>'' and DATEDIFF(year,cast(ColA as datetime), GETDATE()) = 1
SELECT * from TABLENAME where isdate(ColA)=1 and (ColA)<>'' and CAST(ColA AS DATETIME)...
March 29, 2013 at 8:06 am
I would ask why do you need a function for this at all? All you need to do is directly join to your calendar table. I don't see that this...
March 29, 2013 at 7:52 am
Not totally sure how you want the output but this should at least get you started.
;with MyAverage as
(
SELECT Curr_date, Action, AVG(Duration)/1000 as Avg_Duration
FROM Table_1
WHERE Curr_date = CAST(GETDATE() as DATE)
GROUP BY...
March 29, 2013 at 7:47 am
Love & Peace (3/29/2013)
Absolutely !Thats exactly what I was looking for !
Thank you Sean Lange !
You're welcome. Glad that worked for you and thanks for letting me know. 😀
March 29, 2013 at 7:42 am
Viewing 15 posts - 8,851 through 8,865 (of 15,381 total)