+ Reply to Thread
Results 1 to 3 of 3

Thread: many rows w/two columns i need max value return for row

  1. #1
    Registered User
    Join Date
    10-16-2008
    Location
    Modesto
    Posts
    10

    Question many rows w/two columns i need max value return for row

    Good afternoon! I think this is a relatively simple thing to do, but I do now know how! I am using MS Access 2007

    Here is a sample of my data table. Top row is column headings. This is a multi-row table. Columns seperated by -

    Product - Week - column 1 value - column 2 value
    LEGS - WK1 - 20 - 40
    DRUMS - WK4 - 60 - 0

    I need to have the query return the following:
    LEGS - WK1 - 40
    DRUMS - WK4 - 60

    I need SQL code or another way of bringing back the max value of column 1 value and column 2 value in my query results.
    Last edited by jonbdraco; 10-26-2011 at 03:42 PM.

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: many rows w/two columns i need max value return for row

    In a new column in a query type
    Max Value: IIF([Column 1 Value] > [Column 2 Value], [Column 1 Value], [Column 2 Value])

    Make sure that the check box to display Columns 1 and Columns 2 are unchecked in your query.

    Your SQL Statement would look something like this:

    Select Product, Week, IIF([Column 1 Value] > [Column 2 Value], [Column 1 Value], [Column 2 Value]) As Max Value
    FROM YourTableName;
    Alan

  3. #3
    Registered User
    Join Date
    10-16-2008
    Location
    Modesto
    Posts
    10

    Re: many rows w/two columns i need max value return for row

    awesome!!! That worked! Thank you sooo much. This is a pretty dang easy solution

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0