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
 General SQL Server Forums
 New to SQL Server Programming
 Query help for Date field

Author  Topic 

Sambasivam
Starting Member

36 Posts

Posted - 2009-07-28 : 15:07:07
I have a field (date time). I need to extract weekly rows from the table using the date time field starting with least date in the table.
For Example if the field has these data

2000-12-06
2000-12-06
2000-12-06
2000-12-06
2000-12-06
2000-12-06
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-07
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-08
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-11
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-12
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-13
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-14
2000-12-15
2000-12-15
2000-12-15
2000-12-16
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-18
2000-12-19
2000-12-19
2000-12-19
2000-12-19
2000-12-19

the query should fetch 2000-12-06 and row with one week later from here
and then next date to week later.

Please help me with some ideas

X002548
Not Just a Number

15586 Posts

Posted - 2009-07-28 : 15:21:21
post what your sample result set should look like...

However....rows of data in a table are not related to each other



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-28 : 16:36:36
like this?
SELECT MIN(Field), DATEADD(WEEK, 1 MIN(Field))
FROM MyTable
GROUP BY Field
Go to Top of Page

Sambasivam
Starting Member

36 Posts

Posted - 2009-07-28 : 17:20:28
I want it like this

Col1 Col2
2000-12-06 2000-12-12
2000-12-13 2000-12-19
2000-12-20 2000-12-26

and so on
Go to Top of Page

Sambasivam
Starting Member

36 Posts

Posted - 2009-07-29 : 10:54:32
Isn't there anyone who can give some help for this. Does it mean that it is not possible to do so?
Go to Top of Page
   

- Advertisement -