Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 help needed in running this query

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2010-02-23 : 07:29:20
hi, here is my query

DECLARE @TestVal int;
SET @TestVal = select DATEDIFF(ss,loadendtime,timeackcreated)/3600.0 from sample_current
SELECT
CASE
WHEN @TestVal > 3 THEN 'Not sent'
WHEN @TestVal < =3 THEN 'sent'
ELSE 'Other'
END

if i run this query it is not working, it shows error. what could be the problenm here? the output of the select DATEDIFF(ss,loadendtime,timeackcreated)/3600.0 from sample_current
will be 4 to 5 rows of data. so how to do this using procedure or query. please help me

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-23 : 07:35:23
select
case
when DATEDIFF(ss,loadendtime,timeackcreated)/3600.0 > 3 then 'not send'
when DATEDIFF(ss,loadendtime,timeackcreated)/3600.0 <= 3 then 'sent'
else 'other'
end as Column_Name
from sample_current


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-23 : 07:37:46

select
case
when DATEDIFF(ss,loadendtime,timeackcreated)/3600.0 > 3 THEN 'Not sent'
when DATEDIFF(ss,loadendtime,timeackcreated)/3600.0 < 3 THEN 'sent'
else 'Other'
end
from sample_current


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-23 : 07:38:20


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-23 : 07:41:30
I wondered how we posted in the same alignment of code

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-23 : 07:44:32
It is not the first time - maybe we are twins


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-23 : 07:47:02
quote:
Originally posted by webfred

It is not the first time - maybe we are twins


No, you're never too old to Yak'n'Roll if you're too young to die.


Not the first time?
Can you show anyother threads that happened like this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-23 : 07:51:16
http://www.sqlteam.com/FORUMS/topic.asp?TOPIC_ID=128961


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-23 : 07:54:44
quote:
Originally posted by webfred

http://www.sqlteam.com/FORUMS/topic.asp?TOPIC_ID=128961


No, you're never too old to Yak'n'Roll if you're too young to die.


Fantastic

Good that you remember that

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2010-02-23 : 23:12:38
Thank you guys.
Go to Top of Page
   

- Advertisement -