﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 7,2000 / T-SQL  / Query-restrict output / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 06:59:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query-restrict output</title><link>http://www.sqlservercentral.com/Forums/Topic1384935-8-1.aspx</link><description>Thanks looks like this will work. Thanks everyone for your input.  Evena  50yr can still learn things..:cool:</description><pubDate>Fri, 16 Nov 2012 21:18:09 GMT</pubDate><dc:creator>Peter D-251663</dc:creator></item><item><title>RE: Query-restrict output</title><link>http://www.sqlservercentral.com/Forums/Topic1384935-8-1.aspx</link><description>I don't know the whole structure of your table, but this might give you something to start.You might need to add some fields or add the extra time to get the 00:59:50.Be aware that BETWEEN is inclusive for both values, so you might have values that get in two days.[code="sql"]CREATE TABLE #PSACCESSLOG(	oprid	varchar(6),	logindttm	datetime)INSERT INTO #PSACCESSLOG SELECT 'jbaker', '2012-06-01 00:50:59.000' UNION ALLSELECT 'jbaker', '2012-06-01 12:50:59.000'  UNION ALLSELECT 'jbaker', '2012-06-01 15:50:59.000' SELECT oprid, 	DATEADD( dd, DATEDIFF( dd, 0, LOGINDTTM), 0) AS LOGINDT, 	COUNT(*) AS entriesFROM #PSACCESSLOGWHERE LOGINDTTM BETWEEN '2012-06-01 00:50:59.000' AND '2012-07-01 00:50:59.000'GROUP BY oprid, DATEADD( dd, DATEDIFF( dd, 0, LOGINDTTM), 0)ORDER BY OPRID, LOGINDTDROP TABLE #PSACCESSLOG[/code]</description><pubDate>Thu, 15 Nov 2012 09:12:30 GMT</pubDate><dc:creator>Luis Cazares</dc:creator></item><item><title>RE: Query-restrict output</title><link>http://www.sqlservercentral.com/Forums/Topic1384935-8-1.aspx</link><description>When there are multiples which one do you want? It be far more helpful if you could post ddl and sample data with your problem. See the first link in my signature for best practices when posting questions.</description><pubDate>Thu, 15 Nov 2012 07:28:23 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>Query-restrict output</title><link>http://www.sqlservercentral.com/Forums/Topic1384935-8-1.aspx</link><description>I have a system that logs users who use the system daily.  Some user may log in several times during the day which creates additional entries into the logging table in a date format as "'2012-06-01 00:50:59.000' "What I'm trying to do is query and return back just one entry for the user (s) even if they are captured in the logging table more than once per day (i.e. jbaker .'2012-06-01 00:50:59.000' '2012-06-01 12:50:59.000' '2012-06-01 15:50:59.000' )I tried selecting distinct user (oprid) from the logging table (psaccesslog)but still came back with multiple entries for the day.SELECT  * FROM PSACCESSLOGWHERE LOGINDTTM BETWEEN '2012-06-01 00:50:59.000' AND '2012-07-01 00:50:59.000'ORDER BY OPRID, LOGINDTTMAppreciate insight</description><pubDate>Wed, 14 Nov 2012 17:11:14 GMT</pubDate><dc:creator>Peter D-251663</dc:creator></item></channel></rss>