...

MSSQL: Select Statement w/MIN Problem

efeller
05-20-2007, 03:16 PM
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

javabits
05-23-2007, 07:40 PM
Try adding a group by customer_id


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...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum