Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2004, 02:28 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vitor_mrm
Default Some Query Problems

Hello, I've got some tables like this, and i can't get the query:

tblPlace
-------------
PlaceID
OwnerID
Name
Address
InsertDate

tblContracts
---------------
ContractID
PlaceID
RentPersonID
StartDate
EndDate

The Query should return:

tblPlace.PlaceID
Status (If exists a contract that is not over status is Ocupied, if not is Open)

One of this:
tblPlace.InsertDate (if doen't exist any contract)
tblContract.StartDate (if contract is not over)
tblContract.EndDate (if contract is over)

tblContract.RentPesonID (and the name is tblRentPeson)

Thanks for any info...
 
Old May 16th, 2004, 04:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT PlaceID, IIF([tblContracts].[EndDate]<Now(),"Ocupied", "Open") AS [Status], Min([tblPlace].[InsertDate]) As [Insert], Min([tblContract].[StartDate]) As [Start], Min([tblPlace].[EndDate]) As [End], tblContract.RentPersonID FROM tblContracts GROUP BY PlaceID, IIF([tblContracts].[EndDate}<Now(),"Ocupied", "Open")


(I haven't tested this, so there may be a typo somewhere.


Steven


I am a loud man with a very large hat. This means I am in charge
Of course - there was an obvious typo
 
Old June 4th, 2004, 04:27 AM
Registered User
 
Join Date: May 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi! I try using such statement but can only get three column(placeID, status and date)

SELECT tblContracts.PlaceID,
IIf(Max([tblContracts].[EndDate])>=Now(),'Occupied','Open') AS Status,
IIf(status='Open',Max([tblcontracts].[endDate]),Max([tblcontracts].[startdate])) AS dDate
FROM tblContracts
GROUP BY tblContracts.PlaceID;
Union
SELECT tblPlace.PlaceID, 'Open' AS Status, tblPlace.InsertDate AS dDate
FROM tblContracts RIGHT JOIN tblPlace ON tblContracts.PlaceID = tblPlace.PlaceID
WHERE (((tblContracts.PlaceID) Is Null));


can anyone pls kind tell me how to get the results showing rentpersonID as one of the result?

thanks!

snowbelly.






Similar Threads
Thread Thread Starter Forum Replies Last Post
this Newbie has adp / stored query problems - LeoTiger1 BOOK: Access 2003 VBA Programmer's Reference 0 June 13th, 2006 03:40 PM
Problems with multiple total query. cstooch Classic ASP Databases 0 May 14th, 2006 02:09 PM
VBA Query Problems LiamBFC Access VBA 2 April 11th, 2006 06:26 AM
Query Problems lildragon88 Access 0 February 11th, 2005 05:38 PM
problems with related query apek PHP How-To 5 February 4th, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.