473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

faster query



Hi all,

I have a table with a field of datetime (0000-00-00 00:00:00), in order
to get a unique list of what are the years available in the database
records, I use:

Select YEAR(datetime) from data group by YEAR(datetime);

which returns:
------------------
| YEAR(datetime) |
-------------------
| 1998|
| 1999|
| 2000|
| 2001|
| 2002|
| 2003|
| 2004|
|------------------|
7 rows in set (2.59 sec)
There are total of 44251 rows in the data table. Is there a better way
to get the year list?

Thanks in advance,

sheng

Jul 19 '05 #1
2 2359
index the field

"bunnytail" <no****@spam.com> wrote in message
news:40**************@spam.com...


Hi all,

I have a table with a field of datetime (0000-00-00 00:00:00), in order
to get a unique list of what are the years available in the database
records, I use:

Select YEAR(datetime) from data group by YEAR(datetime);

which returns:
------------------
| YEAR(datetime) |
-------------------
| 1998|
| 1999|
| 2000|
| 2001|
| 2002|
| 2003|
| 2004|
|------------------|
7 rows in set (2.59 sec)
There are total of 44251 rows in the data table. Is there a better way
to get the year list?

Thanks in advance,

sheng

Jul 19 '05 #2
index the field

"bunnytail" <no****@spam.com> wrote in message
news:40**************@spam.com...


Hi all,

I have a table with a field of datetime (0000-00-00 00:00:00), in order
to get a unique list of what are the years available in the database
records, I use:

Select YEAR(datetime) from data group by YEAR(datetime);

which returns:
------------------
| YEAR(datetime) |
-------------------
| 1998|
| 1999|
| 2000|
| 2001|
| 2002|
| 2003|
| 2004|
|------------------|
7 rows in set (2.59 sec)
There are total of 44251 rows in the data table. Is there a better way
to get the year list?

Thanks in advance,

sheng

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Assume you have two varchar (or Text) columns named L and U which are identical except that the charset for L is latin1 and the charset for U is utf8. All the records in L and U are identical in...
2
by: ruben | last post by:
Hi: I must have missed something, but how is it possible that a join on tables A and B is faster (a lot faster) than a query to one of the tables with the same conditions? The problem seems...
3
by: Not Me | last post by:
Hi, In the past I seem to have been able to speed up queries by making them a join rather than ... not a join :o) An example would be select * from x where a in (select a from y) would...
1
by: Danny Dy | last post by:
Hi To All, I always write My VBA code in SQL(see Example). Private Sub cbxAEName_NotInList(NewData As String, Response As Integer) Dim stSQL as String Dim strMsg As String strMsg = "'" &...
2
by: mark | last post by:
I've got an 83-page report which contains an Microsoft Graph 8 Chart, but the report takes FOREVER to format, probably because the row source is a bit complex: TRANSFORM...
3
by: mathilda | last post by:
When I'm opening a recordset for add new, is it faster to put a limiting clause on it? i.e. does "Select from Where Keyfield = " & value & " return a recordset faster than "Select ...
9
by: VenuGopal | last post by:
Hi, why n++ executes faster than n+1..... or does it realli execute faster? thanks Venugopal.B
6
by: SKG | last post by:
I have two databases with in same sql server. I want to know whether a join of two tables with in same database is faster or than join of tables across two databases Thanks!!!
2
by: RichardP via AccessMonster.com | last post by:
Hi there, I have a query running against Oracle which returns approx. 140,000 records. I need to store all this data locally in my BE database. Conventionally I would set up a table to contain...
27
by: Cleverbum | last post by:
I currently have a list of md5 strings and need to check if a new string is in that list hundreds of thousands of times. I've found that the fastest way to do this is to have all the md5's stored...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.