SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to modify this query to get the row count
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kshahzad
Starting Member

45 Posts

Posted - 07/04/2013 :  01:15:45  Show Profile  Reply with Quote
I want to modify this query to
return row count


DECLARE @dCurrentTimeDATETIME

DECLARE @dCurrentTimeMinus5DATETIME


SET @dCurrentTime=GETDATE()

SET @dCurrentTimeMinus5=DATEADD(minute,-5, @dCurrentTime)


--Return lIDS for only sessions last accessed in the last 5 minutes

SELECT lID,MAX(dLastAccessed)

FROM SessionState_Variables

WHERE dLastAccessedBETWEEN @dCurrentTimeMinus5AND @dCurrentTime

GROUPBY lID

ORDERBY 2DESC

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/04/2013 :  01:24:11  Show Profile  Reply with Quote

DECLARE @dCurrentTimeDATETIME

DECLARE @dCurrentTimeMinus5DATETIME


SET @dCurrentTime=GETDATE()

SET @dCurrentTimeMinus5=DATEADD(minute,-5, @dCurrentTime)


--Return lIDS for only sessions last accessed in the last 5 minutes

SELECT COUNT(*)
FROM SessionState_Variables
WHERE dLastAccessed =
(SELECT MAX(dLastAccessed)

FROM SessionState_Variables

WHERE dLastAccessed BETWEEN @dCurrentTimeMinus5AND @dCurrentTime
)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

kshahzad
Starting Member

45 Posts

Posted - 07/04/2013 :  19:12:05  Show Profile  Reply with Quote
this worked thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/05/2013 :  01:26:57  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000