473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How do I use the "DISTINCT" command

I use the following SQL command in my ASP webpage...

SELECT DISTINCT CarList,CarListID FROM Model

My problem is that I would like for "CarList" to be distinct and not
"CarListID". How can I fix this problem?
Jul 19 '05 #1
3 6858
You must then specify what value of CarListID you wish to retrieve for a
given value of CarList. For example,

select CarList, CarListID
from Model M1
where CarListID = (
select top 1 CarListID
from Model M2
where M2.CarList = M1.CarList
order by ...
)

SK

michaaal wrote:
I use the following SQL command in my ASP webpage...

SELECT DISTINCT CarList,CarListID FROM Model

My problem is that I would like for "CarList" to be distinct and not
"CarListID". How can I fix this problem?


Jul 19 '05 #2
Possibly you can use GROUP BY to get the result you want:

SELECT carlist, MIN(carlistid) AS carlistid
FROM Model
GROUP BY carlist

This is the easiest way to return the mimimum or maximum value of Carlistid
for each Carlist. If you have other columns that you want to include then
you probably need something more like the example that Steve Kass posted.

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 19 '05 #3
>
SELECT carlist, MIN(carlistid) AS carlistid
FROM Model
GROUP BY carlist

This is the easiest way to return the mimimum or maximum value of Carlistid for each Carlist. If you have other columns that you want to include then
you probably need something more like the example that Steve Kass posted.

--
David Portas
------------
Please reply only to the newsgroup
--


Awesome. Thanks guys.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dmitri | last post by:
Hi there, Does anybody know what is DB2 UDB admin API equivalent to "db2 terminate" command? Some background: I'm developing monitoring application(http://chuzhoi_files.tripod.com). I want...
3
by: Colleyville Alan | last post by:
I am constructing a SQL command from a function. Some code builds the WHERE clause in a looping structure and passes that as an argument to the SQL-building function. But the results do not...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other...
28
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. ...
4
by: Trapulo | last post by:
I've a webservice with a string parameter. I call this webservice passing a string that is 1129 chars length. On the webservice, the received string is 1146 length (I tested sizes with...
12
blyxx86
by: blyxx86 | last post by:
Any idea how to run some SQL that would not Select distinct, but would select the values that are not distinct. Or something like "Select Duplicate"
17
by: pbd22 | last post by:
Hi. How does one return a range of rows. I know that "Top 5" will return rows 0 - 5 but, how do I get 6 - 10? thanks
6
by: py_genetic | last post by:
Hi, I'm looking to generate x alphabetic strings in a list size x. This is exactly the same output that the unix command "split" generates as default file name output when splitting large...
5
by: annCooper | last post by:
Exchange Rates Source file: Exchange.cs Input file: Exchange.in Output file: Exchange.out Using money to pay for goods and services usually makes life easier, but sometimes people prefer to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.