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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select Records in a Range

Author  Topic 

itsashu
Starting Member

2 Posts

Posted - 2007-06-05 : 09:43:47
All ,


I have the below records in table



col1 col2 col3 col4

XYZ Mar-12-2004 123 160234

XYZ Mar-12-2004 123 160235

XYZ Mar-12-2004 123 160236

XYZ Mar-12-2004 123 160244



In above 3 records the col4 values are varying by 1 or 2 and i need to get only one record for those 3 records by calculating the mode of col4 value for all three rows i.e the ouput should be





XYZ Mar-12-2004 123 160235



Please let me know how can i do this.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-05 : 10:13:18
What is your criteria ? The diff in value of col4 in less than or equal to 2 ?

How about if you have a row with col4 = 160239. Will you want to consider this row also ?


KH

Go to Top of Page

itsashu
Starting Member

2 Posts

Posted - 2007-06-05 : 10:22:34
The Difference in col4 values will be maximum by 2 i.e all values vary by difference of 1 or 2 i need one row for that combination ( here key can be considerd as col1+ col2 + col3) .

No if there is a value 160239 with respect to given values then this is a seperate row
Go to Top of Page
   

- Advertisement -