GTC-KTX
asked on
only unique values in query
the following is the rowsource for a combobox.
SELECT SUPPLIERpricing.ID, SUPPLIERpricing.TERM
FROM SUPPLIERpricing
ORDER BY SUPPLIERpricing.TERM;
this query returns
12
12
24
24
24
i want it to only return a number once
12
24
how can i adjust my query to do this
SELECT SUPPLIERpricing.ID, SUPPLIERpricing.TERM
FROM SUPPLIERpricing
ORDER BY SUPPLIERpricing.TERM;
this query returns
12
12
24
24
24
i want it to only return a number once
12
24
how can i adjust my query to do this
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For a combo box... maybe you're displaying the Term field (as the Label), and the Value is the ID field. In which case, you want to decide which ID you want, and maybe use:
SELECT MIN(ID) as ID, TERM
FROM SUPPLIERpricing
GROUP BY TERM
ORDER BY TERM;
Rob
SELECT MIN(ID) as ID, TERM
FROM SUPPLIERpricing
GROUP BY TERM
ORDER BY TERM;
Rob
ASKER
selectdistinct isn't working for me.
Rob,
your methods do not get rid of the multiple similar values, it simply groups them, is that correct
Rob,
your methods do not get rid of the multiple similar values, it simply groups them, is that correct
You propose two fields for one column in your original question, what's field do you want to output on each row ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
GROUP BY and DISTINCT are very similar, except that GROUP BY will allow aggregate functions to be used. Because you have a second field involved, you should use GROUP BY and have an aggregate function on the other field.
Rob
Rob
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Shru - I think you mean to partition by TERM, not ID. And you can't use ORDER BY in the subquery (the one outside the OVER clause).
@GTC - Shru's code is designed to create a FIRST(ID) kind of functionality.
Rob
@GTC - Shru's code is designed to create a FIRST(ID) kind of functionality.
Rob
ASKER
Guys,
I think i sent you on a wild goose chase. My query was not intended to have the field ID. So from your posts you called that to my attention. Once this was removed, it is a simple Select Distinct. As far as points, i am just splitting up evenly by all that responded. Thanks for taking the time to help!
I think i sent you on a wild goose chase. My query was not intended to have the field ID. So from your posts you called that to my attention. Once this was removed, it is a simple Select Distinct. As far as points, i am just splitting up evenly by all that responded. Thanks for taking the time to help!
Thanks for the points!
Open in new window