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 > PC based Database Applications > Corel Paradox > Calculating row number using correlated subquery

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-10, 18:59
jmalone68 jmalone68 is offline
Registered User
 
Join Date: Jun 2006
Posts: 3
Calculating row number using correlated subquery

Hello All,

I want to generate row numbers on a Paradox table.
The following code works on my SQL server but not on Paradox.
SELECT TT.Hours,
(SELECT COUNT(*)
FROM "TopTenTable.DB" TT2
WHERE TT2.Hours <= TT.Hours
) As Num
FROM "TopTenTable.DB" TT
ORDER BY TT.Hours
The values for 'Num' are zero (0).
Does anyone know if Paradox Local SQL has a problem with correlated sub-queries of this type.

Any other suggestions of how I might calculate the row number would also do the trick, using LocalSQL or QBE. I'm not fussy.

Thanks in advance,
John
Reply With Quote
  #2 (permalink)  
Old 02-09-10, 19:09
jmalone68 jmalone68 is offline
Registered User
 
Join Date: Jun 2006
Posts: 3
Found the solution using different method

OK, I managed to find a solution on the forums here that will do the trick.
(It's always AFTER you've asked the question that you find the answer, I don't know why.)
SELECT TT.Hours, TT.Class, COUNT(*) AS RowNum
FROM "TopTenTable.DB" TT
JOIN "TopTenTable.DB" TT2
ON TT2.Hours <= TT.Hours
GROUP BY TT.Hours, TT.Class
ORDER BY TT.Hours

This should do the trick for me.

If anyone has any idea as to why the correlated subquery didn't work I'd still really like to know.

Thanks,
John
Reply With Quote
  #3 (permalink)  
Old 02-10-10, 07:00
Steve Green Steve Green is offline
Registered User
 
Join Date: Dec 2007
Posts: 282
I can't tell you if that is supported in Local SQL, but in native QBE it is not.. you would scan the table after the query to seed a "record number" field, if needed..
__________________
--
Steven Green - Myrtle Beach, South Carolina USA

http://www.OasisTradingPost.com

Oasis Trading Post
- Collectibles and Memorabilia
- Vintage Lego Sets and Supplies
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