Stuart McLachlan
stuart at lexacorp.com.pg
Thu Apr 2 17:38:07 CDT 2009
Habit. I always use Distinct with Group By queries whether it is necessary or not. It doesn't do any harm and I don't have to stop and think about whether I need to use Distinct on a specific occasion. :-) Stuart On 2 Apr 2009 at 17:44, jwcolby wrote: > You da man (again). Why distinct? > > John W. Colby > www.ColbyConsulting.com > > > Stuart McLachlan wrote: > > You mean something like: > > > > Select Distinct, Int(PKID/1000000) as PKMegRange, Count(*) as Records > > from myTable > > Group By Int(PKID/1000000) > > Order by Int(PKID/1000000) > > > > On 2 Apr 2009 at 14:51, jwcolby wrote: > > > >> You could do that. But I need it to show me steps of X PKID. Perhaps > >> every 1 meg PK over 50 megs of records. > > ,,, > >> Charlotte Foust wrote: > >>> Maybe this is too simple, but wouldn't you just select Count(PKID) Where > >>> PKID less than or equal to PKID Z and Greater than or equal to PKID Y? > >>> -----Original Message----- > > ... > >>> I need to get a count of records in a PK range in SQL Server. For > >>> example I need to know that there are X addresses between PKID Y and > >>> PKID Z. > >>> > >>> Any idea how to do this in tsql? > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com