|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Year only data from daily datesSELECT [obsDate] FROM [tblObs] returns 3653 datevalue records for each day. 1995-01-01 00:00:00 1995-01-02 00:00:00 1995-01-03 00:00:00 ---------------------- ---------------------- 2004-12-29 00:00:00 2004-12-30 00:00:00 2004-12-31 00:00:00 I just want a recordset having years. That means with only 10 records as follow. 1995 1996 1997 ----- ----- 2004 What should be the SQL query? I do not know anything about objectDataSource of ADO.NET. Is it worthwhile or better for this kind of problem? Thanks for reading this ... Regds, Web learner Try:
select distinct Year (obsDate) as 'Year' from tblObs -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA SQL Server MVP Toronto, ON Canada .. "Web learner" <begin***@learning.edu> wrote in message I have daily data from year 1995 to 2004. The following querynews:OSTG4DFWGHA.3492@TK2MSFTNGP05.phx.gbl... SELECT [obsDate] FROM [tblObs] returns 3653 datevalue records for each day. 1995-01-01 00:00:00 1995-01-02 00:00:00 1995-01-03 00:00:00 ---------------------- ---------------------- 2004-12-29 00:00:00 2004-12-30 00:00:00 2004-12-31 00:00:00 I just want a recordset having years. That means with only 10 records as follow. 1995 1996 1997 ----- ----- 2004 What should be the SQL query? I do not know anything about objectDataSource of ADO.NET. Is it worthwhile or better for this kind of problem? Thanks for reading this ... Regds, Web learner Yes, it worked. This is what I wanted for the moment.
Thanks...... Show quote "Tom Moreau" <tom@dont.spam.me.cips.ca> wrote in message news:ufjVPHFWGHA.4132@TK2MSFTNGP04.phx.gbl... > Try: > > select distinct > Year (obsDate) as 'Year' > from > tblObs > > -- > Tom > > ---------------------------------------------------- > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA > SQL Server MVP > Toronto, ON Canada > . > "Web learner" <begin***@learning.edu> wrote in message > news:OSTG4DFWGHA.3492@TK2MSFTNGP05.phx.gbl... > I have daily data from year 1995 to 2004. The following query > SELECT [obsDate] FROM [tblObs] > returns 3653 datevalue records for each day. > > 1995-01-01 00:00:00 > 1995-01-02 00:00:00 > 1995-01-03 00:00:00 > ---------------------- > ---------------------- > 2004-12-29 00:00:00 > 2004-12-30 00:00:00 > 2004-12-31 00:00:00 > > I just want a recordset having years. That means with only 10 records as > follow. > > 1995 > 1996 > 1997 > ----- > ----- > 2004 > > What should be the SQL query? > > I do not know anything about objectDataSource of ADO.NET. Is it worthwhile > or better for this kind of problem? > > Thanks for reading this ... > > Regds, > > Web learner > > |
|||||||||||||||||||||||