Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old April 19th, 2004, 02:57 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Choosing max values from different tables

Hi!

I would be very happy if anybody could help me in the following.

I have two tables:

table 1:
Identifyer Date(D/M/Y) Actual description
morning doings 01/02/2004 I stood up at 10:00
lunch 02/02/2004 I ate soup

table 2:
Identifyer Date(D/M/Y) Various description
morning doings 01/02/2004 I did not go to work
morning doings 01/03/2004 I had to call my girlfriend
lunch 02/01/2004 I like cookies
lunch 12/01/2004 The soup was very hot

And I would like to get the maximum record from this two different Excel tables:

table 3 (from tables 1 and tables 2):
Identifyer Date(D/M/Y) Latest description
morning doings 01/03/2004 I had to call my girlfriend
lunch 02/02/2004 I ate soup

Can this problem be hadles in any way?

Thanks:

pontitt

  #2 (permalink)  
Old April 22nd, 2004, 12:01 PM
Authorized User
 
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Need more detail, you've got 2 excel tables but where are you trying to link them and how.

With-in excel ?
Using SQL throught some odbc driver ?
Using recordsets in VB ?
Are both table in the same excel file ?


  #3 (permalink)  
Old April 26th, 2004, 01:38 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

>Need more detail, you've got 2 excel tables but where are you trying to link them and how.

>With-in excel ?
Yes, from two separate excel files <<File1.xls>>; <<File2.xls>>
>Using SQL throught some odbc driver ?
Yes, through ODBC;DSN=Excel files;DBQ=Path of the active workbook
>Using recordsets in VB ?
If it is possible, I would not like to use recordsets (just one SQL query)
>Are both table in the same excel file ?
No, they aren't.

Sorry not to be able clearly explaining my problem. I would just like to get maximum data from two different excel files with one query, as I showed previously.

Thank in advance for your help:

pontitt

  #4 (permalink)  
Old April 28th, 2004, 05:10 AM
Authorized User
 
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT Identifier, Date, Description1
FROM (SELECT Identifier, Date, VariousDescription AS Description1
         FROM Table2
         UNION
         SELECT Identifier, Date, ActualDescription AS Description1
         FROM Table1) DERIVEDTBL1
WHERE (date = (SELECT MAX(date)
                   FROM (SELECT Identifier, Date, VariousDescription AS Description1
                             FROM Table2
                             UNION
                             SELECT Identifier, Date, ActualDescription AS Description1
                             FROM Table1) DERIVEDTBL2
                   WHERE identifier= DERIVEDTBL1.Identifier))



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting values from other tables TheAndruu SQL Language 7 May 27th, 2007 10:47 AM
SQL script for selecting min and max values Nancy Krause Need help with your homework? 0 April 12th, 2007 11:29 AM
passing values between two tables bright_mulenga Access 1 January 24th, 2007 11:27 AM
How to set of Min/Max values of Line chart . Sanjay.Verma BOOK: Professional Crystal Reports for VS.NET 0 November 20th, 2006 11:35 PM
Impure numeric values passed to MAX() Daniel Walker PHP Databases 4 April 8th, 2004 03:23 AM





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