473,408 Members | 1,852 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,408 software developers and data experts.

What type of query will return the correct results?

1
I have no idea what sql command will return the results I need from 1 table.

example of table and values

col1 col2 col3(unique values)
1 1 abc
1 1 dev
1 2 rst
1 3 ndb
1 3 mnv

I need an sql query, that returns the distinct combined values of col1
and col2 and the first value of that distinct combination from col3.


return values should be;
1 1 abc
1 2 rst
1 3 ndb
Sep 10 '10 #1
1 1470
select r,c1,c2,c3
from table(
select row_number() over(partition by c1,c2 order by c3) r, c1, c2, c3 from table(values (1,1, 'abc'), (1, 1, 'dev'),(1, 2, 'rst'),(1, 3, 'ndb'),(1, 3, 'mnv')) t(c1,c2,c3) order by c1,c2,c3
)
where r=1
Oct 9 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Börni | last post by:
Hi, I have an sql query like this: SELECT column FROM table WHERE column1="3" AND column2="1" This query works perfectly if i run it in the command line, to be exactly it return two results. But...
2
by: yawnmoth | last post by:
i'm using an entry in an sql database as a semaphore and it, unfortunately, doesn't appear to be working. the script that spawns the child processes has a for loop that performs the same basic sql...
0
by: Chris | last post by:
Hi all - Hope you can help me with this SQL / PHP problem. I have the following tables with (in brackets) the following columns: PLAYER (playerid, forename, surname, birthdate, birthplace)...
4
by: Andy Davis | last post by:
I have developed a number of reports that are based on parameter queries where the user enters criteria such as a date range and a sales rep say. I want to be able to show a graphical picture in...
2
by: Gary Brown | last post by:
Hi, In the good old days of Borland C++ the debugger would show a function's return value when single stepping or at a break at the closing '}'. Is there a similar capability in VS 2005? ...
3
by: CK | last post by:
USE AdventureWorks GO -- Retrieve order manifest SELECT SalesOrder.SalesOrderID,
5
by: garyusenet | last post by:
Console.WriteLine("Current OS: {0} ", Environment.OSVersion) I'm trying to find out what .OSVersion is. It returns an object which details the OS. I know it's not a method, because it doesnt...
31
by: Lane Straatman | last post by:
void s_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { size_t bytes; unsigned char *array, *after, *i, *j, *k, *p1, *p2, *end, swap; array = base;...
2
by: jennk | last post by:
i am working in Access 97, our database tables are linked from ODBCsqlsvr (not even sure what that means). i have a table where each record has a unique customer and their order information. there...
1
by: tjm0713 | last post by:
Not sure this can be done but here is my current situation. I have a table containing millions of records. Each record has 28 fields. One of the fields I am trying to return the single record for...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.