Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-20-2007, 03:16 PM   PM User | #1
efeller
New Coder

 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
efeller is an unknown quantity at this point
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
efeller is offline   Reply With Quote
Old 05-23-2007, 07:40 PM   PM User | #2
javabits
New Coder

 
Join Date: May 2007
Location: SF, CA
Posts: 55
Thanks: 0
Thanked 4 Times in 4 Posts
javabits is on a distinguished road
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...
javabits is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:28 AM.


Advertisement
Log in to turn off these ads.