Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 October 6th, 2007, 01:54 PM
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I have what I want! At the moment I have three seperate queries.

Andrew:

Code:
SELECT [Home Talks].[Congregation], Max([Home Talks].[Last Given]) AS MostRecentDate
FROM [Home Talks]
GROUP BY [Home Talks].[Congregation]
UNION SELECT [Congregations], [Last Invited]
FROM [Congregations]
ORDER BY [MostRecentDate];
Andrew1:

Code:
SELECT Andrew.Congregation, Max(Andrew.MostRecentDate) AS MaxOfMostRecentDate
FROM Andrew
GROUP BY Andrew.Congregation;
Andrew2:

Code:
SELECT Andrew1.Congregation, Congregations.Time, Andrew1.MaxOfMostRecentDate, IIf([MaxOfMostRecentDate]>Now(),"Booked","Old Date") AS Status
FROM Andrew1 INNER JOIN Congregations ON Andrew1.Congregation = Congregations.Congregations
ORDER BY MaxOfMostRecentDate DESC;
This gives me the table I want. I have all the details I want and the date is the right date and the sorting works because the date field is still a date field (the UNION came to the rescue). The IIF or Switch seems to return strings.

So, this does what I want. The question is, can I combine these into one SQL statement?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjust row height of gridview wirerider ASP.NET 2.0 Basics 5 February 1st, 2008 07:01 AM
adjust zone time kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 July 2nd, 2007 08:53 AM
function adjust-dateTime-to-timezone Tomi XSLT 3 July 26th, 2006 11:51 AM
Adjust Pie Chart Size terencechua Reporting Services 0 January 19th, 2006 10:49 PM
How to adjust several SQL scripts in crystal repor juma Crystal Reports 0 July 10th, 2004 01:34 AM





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