Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MSSQL: Select Statement w/MIN Problem

    I have more than one vendor for each county. I need to select the lowest cost vendor and display that record. This select statement works, but it's not selecting the lowest cost vendor. The problem seems to be in the MIN part of the select statement I think Can anyone help me correct this issue?



    pricecolumn=rstemp8("PRICE_COLUMN") 'this tells me which pricing column to use in the table.

    SELECT MIN("&pricecolumn&") AS PRICE,COUNTY_NOTE_VIEWABLE_BY_CUSTOMER FROM tbl_COUNTY_CRIMINAL_VENDOR_ASSIGNMENT WHERE COUNTY_ID="&countyname&" GROUP BY COUNTY_NOTE_VIEWABLE_BY_CUSTOMER

  • #2
    New Coder
    Join Date
    May 2007
    Location
    SF, CA
    Posts
    55
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Try adding a group by customer_id

    Code:
    SELECT MIN("&pricecolumn&") AS PRICE,
               COUNTY_NOTE_VIEWABLE_BY_CUSTOMER
    FROM tbl_COUNTY_CRIMINAL_VENDOR_ASSIGNMENT
    WHERE COUNTY_ID="&countyname&"
    GROUP BY COUNTY_NOTE_VIEWABLE_BY_CUSTOMER
               , CUSTOMER_ID
    semper fi...


  •  

    Posting Permissions

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