Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Perform Query For Each Row in Result Post Reply Post New Topic
Author Message
doraemon
Newbie
Newbie


Joined: 03 Jul 2009
Online Status: Offline
Posts: 3
Quote doraemon Replybullet Topic: Perform Query For Each Row in Result
     Posted: 15 Jul 2009 at 1:33pm
Is there a way to get crystal to perform a query for every row in the result of another query? This will be needed many times on the same query so nested queries are not maintainable.

For example I execute:
SELECT username, SUM(foo)
FROM someTable
WHERE status = 1
GROUP BY username

But for every user, I would also like to get their email, from say:
SELECT email
FROM someOtherTable
WHERE username = thisUser

Using JOINS are also not efficient with aggregated data.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Jul 2009 at 6:23am
nope, Crystal doesn't work that way....well ok, you could write a subreport, but that seems like a tremendous waste of resources...Crystals.  For 100 records, you are going to hit the database 101 times, depending on network traffic, server traffic, and other variables, your report will lag.
 
Why not write a stored proc and let it gather all the data you want and report it back to you, this only 1 hit to the database, and all the data you want is one row, so it much simpler to code the report.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum