Joined: 19 Oct 2009
Location: United States
Online Status: Offline
Posts: 6
Topic: Select Only One Record Posted: 19 Oct 2009 at 9:57am
Issue:
I have multiple tables, ( One client table ) ANother table contains vehicles owned. They have three vehicles. I have a purchased date in this table ( vehicle table ). I only want the "newest" or "latest" or the last one purchased to appear. Not matter how I write it I get multiple reports, even if I use a "command" table. ( I have tried using "maximum" statements with no luck whatsover. When I try to use it in the report selection formula I get an error and tells me "Needs to be evaluated Later" I only want the vehicle name I only need the purchase date to "select" the correct vehicle. ( By the way the client table is a stored procedure with over fifty fields. The link is by Client ID.) Please help
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 19 Oct 2009 at 11:03am
select client, vehicle from
vehicletable as vt join
(select client, max(datebought) as db from table1 join table2 on table1.clientid = table2.clientid) as ss on vt.client = ss.client and vt.datebought = ss.db
Joined: 19 Oct 2009
Location: United States
Online Status: Offline
Posts: 6
Posted: 19 Oct 2009 at 12:38pm
Good intentions ... Still did not work, I still get a report for each vehicle.
I even tried this statement directly in the SQL database still get three entries. In SQL you can only use the Max() statement as a field by itself. ( I cannot ask to link by client. )
P.S. I tried a "sub-report" the same vehicle appears ( the correct one ).However I still get three pages of reports... One I guess for each vehicle.
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 19 Oct 2009 at 12:48pm
I still think Lockwelle's idea will work. If you post your SQL statement that did not work someone should be able to tweak it to work...
However you are just looking for a simple way to display the data go ahead and leave all of the records in the report.
group on Client ID, sort by vehicle date descending, hide the details and place your vehicle info on the group header. It should display the most recent.
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 19 Oct 2009 at 12:49pm
if you need it alpha by client, concantenate the client name and ID # and then group on that. You can hide the group name and just use the client name in the group header.
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