473,387 Members | 1,891 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,387 software developers and data experts.

Query is not producing result

Whenever I am running a query in which FIRST function of access is used, qury just hangs up and does not produce any result. could any one guide on this?
I am using MS Access 2000 and OS is windows server 2003 and SQL 8.0
Jan 28 '08 #1
5 1184
sierra7
446 Expert 256MB
Hi
You will need to post the details of your query. Open it in Design View, then click View, then SQL View

Then copy and paste the test to the forum

An idication of whet you are truing to achieve might also be useful

S7
Jan 28 '08 #2
NeoPa
32,556 Expert Mod 16PB
Another point to consider :
Dou you really want First(), or would maybe the DISTINCTROW predicate of the SELECT clause suit you better?
Jan 28 '08 #3
This is the query I am trying to run
Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIR] AS zCLIR, First([LIR]) AS zLIR, First([Prefix]) AS zPRE, First([FirstName]) AS zFN, First([MI]) AS zMI, First([LastName]) AS zLN, First([StandardTitle]) AS zTL FROM [sql_DDMContact] GROUP BY CLIR HAVING CLIR >= 0
This query always hangs but when I remove the first() function it works out.
Please guide on this. this table sql_DDMContact is a link table in mdb
Jan 31 '08 #4
jaxjagfan
254 Expert 100+
This is the query I am trying to run
Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIR] AS zCLIR, First([LIR]) AS zLIR, First([Prefix]) AS zPRE, First([FirstName]) AS zFN, First([MI]) AS zMI, First([LastName]) AS zLN, First([StandardTitle]) AS zTL FROM [sql_DDMContact] GROUP BY CLIR HAVING CLIR >= 0
This query always hangs but when I remove the first() function it works out.
Please guide on this. this table sql_DDMContact is a link table in mdb
Does the CLIR value occur multiple times, assigned to different people and you are trying to get the 1st person it was assigned to?

Otherwise:
Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIR] AS zCLIR, [LIR] AS zLIR, [Prefix] AS zPRE, [FirstName] AS zFN, [MI] AS zMI, [LastName] AS zLN, [StandardTitle] AS zTL
  2. FROM [sql_DDMContact]
  3. WHERE CLIR >= 0
  4. GROUP BY CLIR, LIR, Prefix, FirstName, MI, LastName, StandardTitle
If it is a very large dataset in your linked tables and you are using First, Last, Min, Max type values you may want to go to the properties of the query and set TimeOut to 0. This will prevent the 60 sec timeout.
Jan 31 '08 #5
NeoPa
32,556 Expert Mod 16PB
Firstly, a reminder to everyone to use [ CODE ] tags where possible. This is a requirement of the site and it is there for very good reasons.

Moving on :)
I would only make a minor amendment to your SQL which is to use WHERE instead of HAVING. This may make little difference as the optimiser should catch it for you. The DISTINCT predicate won't help you as there is no (discernable) Primary Index.
Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIR] AS zCLIR,
  2.        First([LIR]) AS zLIR,
  3.        First([Prefix]) AS zPRE, 
  4.        First([FirstName]) AS zFN,
  5.        First([MI]) AS zMI,
  6.        First([LastName]) AS zLN,
  7.        First([StandardTitle]) AS zTL
  8. FROM [sql_DDMContact]
  9. WHERE CLIR >= 0
  10. GROUP BY CLIR
As Jax has said though, change the default timeout value. 0 is fine or I often use 300. That is 5 minutes and in most cases that should return some results or something is wrong. Another setting I'd change would be the Recordset Type from Dynaset to Snapshot.
Jan 31 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Wescotte | last post by:
Here is a small sample program I wrote in PHP (running off Apache 1.3.31 w/ PHP 5.0.1) to help illustrates problem I'm having. The data base is using DB2 V5R3M0. The client is WinXP machine using...
3
by: Aaron Whiffin | last post by:
Hi, I've set up the following table in MySQL 3.23.58 and all seemed to be working fine: CREATE TABLE advert ( id INT NOT NULL AUTO_INCREMENT, userid INT NOT NULL, make VARCHAR(25) NOT NULL,...
1
by: Joshua Belden | last post by:
Okay, how I get myself into these situations, I don't know, but I have to design a component to plug into a C# Windows Forms application that allows the user to design a sql query. I'm thinking of...
20
by: manny | last post by:
I wish I knew what this was called, and I could have made a more sensible subject. For that matter, I knew what it was called, I could have googled it! Anyway, let's I have a table with name,...
7
by: Frankie | last post by:
I'm trying to run the following search query: $query = sprintf ("SELECT itemNumber, thumbnailURL, title, description, price FROM apparel,hats WHERE apparel.title OR apparel.description OR...
2
by: Simon Rigby | last post by:
Hi folks, ASP.NET2, Sql Server 2005 I have an app that executed a sql server query that produces an XML file used as the DateFile for an XMLDataSource bound to a TreeView. The bizarre thing...
1
by: josh2007 | last post by:
hi all, I'm having a hard time producing the correct sql statement for my tables. below is my sql statement but i'm getting incorrect result. This particular query returns the sum of all the...
11
by: lenygold via DBMonster.com | last post by:
Hi everybody! This query is supposed to count consecutive years from the current year without OLAP. Input Table: ID DateCol 1 02/01/2006 1 01/01/2006 1 01/01/2005
6
Lensmeister
by: Lensmeister | last post by:
Hi, As a newbie here I hope someone cane help me. I have Acess 2003 and am making a database that holds records or football matches. I haven't created any relationships as yet. The main table...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.