<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Developer Barn - SQL Development</title>
		<link>http://www.developerbarn.com/</link>
		<description>Structured Query Language (SQL) is the talk of databases. Discuss topics such as joins, triggers and other advanced SQL topics.</description>
		<language>en</language>
		<lastBuildDate>Mon, 06 Sep 2010 12:42:08 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.developerbarn.com/images/misc/rss.png</url>
			<title>Developer Barn - SQL Development</title>
			<link>http://www.developerbarn.com/</link>
		</image>
		<item>
			<title>Aggregates</title>
			<link>http://www.developerbarn.com/sql-development/2244-aggregates.html</link>
			<pubDate>Tue, 31 Aug 2010 19:42:03 GMT</pubDate>
			<description><![CDATA[Ok, I know I'm going to feel really silly when someone answers this because it should be very basic, but I'm at a loss at this point on how to select...]]></description>
			<content:encoded><![CDATA[<div><!-- google_ad_section_start -->Ok, I know I'm going to feel really silly when someone answers this because it should be very basic, but I'm at a loss at this point on how to select a record based on a min/max value.  I realize I can use a Having clause, but it doesn't produce what I want.<br />
<br />
Take the following data:<br />
<br />
Create Table Customer (CustomerId int primary key, DateofBirth int);<br />
Insert Into Customer (CustomerId, DateOfBirth)<br />
Values  (1, 19010801);<br />
Insert Into Customer (CustomerId, DateOfBirth)<br />
Values  (2, 19100101);<br />
Insert Into Customer (CustomerId, DateOfBirth)<br />
Values  (3, 19201201);<br />
<br />
Select * from Customer<br />
<br />
Results:<br />
CustomerId   DateOfBirth<br />
1                 19010801<br />
2                 19100101<br />
3                 19201201<br />
<br />
Ok, so if I want to know the customerid of the person with the min or max date of birth, how would I go about it?<br />
<br />
I can write:<br />
<br />
Select customerid, Min(dateofbirth), Max(dateofbirth)<br />
From Customer<br />
Group by customerid<br />
<br />
<br />
but it just yields all records grouped by customerid.  What if I wanted to see just the customerid and the dateofbirth of the min or max?<br />
<br />
Thanks!<!-- google_ad_section_end --></div>

 ]]></content:encoded>
			<category domain="http://www.developerbarn.com/sql-development/">SQL Development</category>
			<dc:creator>Flam</dc:creator>
			<guid isPermaLink="true">http://www.developerbarn.com/sql-development/2244-aggregates.html</guid>
		</item>
		<item>
			<title>Username Question</title>
			<link>http://www.developerbarn.com/sql-development/2236-username-question.html</link>
			<pubDate>Sun, 29 Aug 2010 21:25:30 GMT</pubDate>
			<description><![CDATA[I've been slightly perplexed at the results of the following query depending on where I'm running it from: 
 
SELECT spid, nt_username 
FROM...]]></description>
			<content:encoded><![CDATA[<div><!-- google_ad_section_start -->I've been slightly perplexed at the results of the following query depending on where I'm running it from:<br />
<br />
SELECT spid, nt_username<br />
FROM sys.sysprocesses <br />
where spid=@@spid<br />
<br />
(I realize I can run SUSER_Name() as well as a variety of other username functions, this is just an example)<br />
<br />
Anyway, I have 2 different modules for an application.  Both of them run on the same database, just out of different ports on the server.  They run from SQL Server 2005.  Both modules have their own built-in query executors (limited functionality; select statements only).<br />
<br />
The thing that confuses me is that if I run the aforementioned query, one module always returns the nt_username value=the local machine username<br />
while the other module returns tthe nt_username=the admin security group in SQL Server.<br />
<br />
So for example, the results from module 1 of the above query might be:<br />
<br />
SPID  nt_username<br />
55     FLAM<br />
<br />
while the results of module 2 might be:<br />
<br />
SPID nt_username<br />
62    T_Admin<br />
<br />
I'm not sure if this is something on the application or something I can change in SQL Server.<br />
<br />
Anyone have any ideas?<br />
<br />
Thanks much!<!-- google_ad_section_end --></div>

 ]]></content:encoded>
			<category domain="http://www.developerbarn.com/sql-development/">SQL Development</category>
			<dc:creator>Flam</dc:creator>
			<guid isPermaLink="true">http://www.developerbarn.com/sql-development/2236-username-question.html</guid>
		</item>
	</channel>
</rss>
