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

SQL Query - distinct with 2 values

I have a table defined as Table1 with rows below

Index Name Value
1 A 1.0 x
1 A 2.0 x
1 A 3.0 x

1 B 1.0
1 B 2.0
1 B 3.0

2 A 4.0 x
2 A 5.0 x
2 A 6.0 x

The output required is marked with x.
I need the output as all rows having the same names in a distinct index. If same index with a different name then ignore. Can anyone help with a simple-to-understand query.

Thanks
SanjayP
Mar 1 '07 #1
3 4066
iburyak
1,017 Expert 512MB
I have a table defined as Table1 with rows below

Index Name Value
1 A 1.0 x
1 A 2.0 x
1 A 3.0 x

1 B 1.0
1 B 2.0
1 B 3.0

2 A 4.0 x
2 A 5.0 x
2 A 6.0 x

The output required is marked with x.
I need the output as all rows having the same names in a distinct index. If same index with a different name then ignore. Can anyone help with a simple-to-understand query.

Thanks
SanjayP
Try this:

[PHP]SELECT * FROM Table1 WHERE Name = 'A'[/PHP]
Mar 1 '07 #2
Thanks for trying.
But its not what I am looking for.. though its correct for my example below its not correct for the whole data I have.

Let me re-define the data rows for a better view
Index Name Value
1 A 1.0 x
1 A 2.0 x

1 B 1.0
1 B 2.0

2 A 4.0 x
2 A 5.0 x

3 B 6.0 x
3 B 7.0 x

3 C 6.0
3 C 7.0

Whatever is the first pair of index and name. I need all rows for that along with the values. (so with a 'group by' I may get the pairs but I lose the values)
I need the rows marked with x.
Mar 1 '07 #3
iburyak
1,017 Expert 512MB
Try this:
[PHP]
SELECT Min(Index), Min(Name), Value
FROM Table1
GROUP BY Value[/PHP]
Mar 2 '07 #4

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

Similar topics

4
by: soni29 | last post by:
hi, i need some help with a query, also to find out if this is even possible with sql. currently i have a table with the following data: CustomerNumber CustomerBranch 123 NULL 123 1...
8
by: Richard | last post by:
This is probably easy but I can't work it out. I have this statement SELECT DISTINCT TOP 100 PERCENT dbo.CIF_PlaceReference.Name FROM dbo.CIF_Departures INNER JOIN dbo.CIF_PlaceReference...
4
by: rong.guo | last post by:
Hello, The population of my analysis is customers that have product1. And I am trying to get the % of them that also have product2, the % of them that also have product3, etc. Now I am doing it...
7
by: Not Me | last post by:
Hi, Having a table with some duplicate ID's (different data tho), how can I return the list but with only one record from each ID? Would this be using the first() function and grouping? ...
6
by: lesperancer | last post by:
SELECT distinct b.t_orno, b.t_pono FROM tblMonthlyBooking AS b, tblFilterDate, tblFilterDate AS tblFilterDate_1 WHERE (((b.t_yearMonth) Between . And .)); tblMonthlyBooking is a sql server...
5
by: usenet | last post by:
Hi. I've been struggling with a query, so I'm hoping that I can explain it in understandable terms. Given the tables PARENT (id, foo, bar) and CHILD (id, type, parent_id), I would like to select...
0
by: phlype.johnson | last post by:
I'm struggling to find the best query from performance point of view and readability for a normalized DB design. To illustrate better my question on whether normalized designs lead to more complex...
8
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
1
newnewbie
by: newnewbie | last post by:
Desperately need help in creating a query to count unique values in a table. I am a Business analyst with limited knowledge of Access….My boss got me ODBC connection to the underlying tables for our...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.