If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Subquery problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-20-04, 10:54
kikker kikker is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
Red face Subquery problem

Hi y'all,

I have a performance problem with a Query in a Paradox Database. I have the following tables (not exactly, just for the Idea)

Table A: 849 rows [ID, Name]
Table B: 27870 rows [ID, Integervalue, Date]

When I try to execute the following Query, the system doesn't react and I have to close the program in the task manager.

SELECT A.Name, B.Integervalue, MAX(B.Date)
FROM tableA A , tableB B
WHERE (A.Id = B.Id)
and B.date in (SELECT MAX(C.date)
FROM tableB C
WHERE C.Id = A.Id)
GROUP BY A.Name, B.Integervalue
ORDER BY A.Name ASC, B.Integervalue ASC

When I don't use the subquery, I get more than 1 result a name... (actually I get count(B.Integervalue) results). Does someone can help me??

Thanks in Advance.
Reply With Quote
  #2 (permalink)  
Old 01-20-04, 11:32
kulkarni_kiran kulkarni_kiran is offline
Registered User
 
Join Date: Jan 2004
Location: Mumbai
Posts: 4
Hi k,

1. edit ur SUBQuery as it should access object A for "tableA" like SELECT MAX(C.date)
FROM tableB C, tableA A
WHERE C.Id = A.Id

So that sys will recognize "what is A.id ?"


or

2. first check ur subquery. Will it work separately then do the changes and then add NEW1 in the statement.

Bye,
K
Reply With Quote
  #3 (permalink)  
Old 01-21-04, 04:11
kikker kikker is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
re

Both of the tips didn't work out... Thanks for the reply anyway. More help is welcome!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On