473,889 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i select one row out of duplicates in a table.

1 New Member
lets say i have a table C with following columns-
C1 C2 C3
1 2 3
1 4 9
2 3 1
1 4 7
3 9 6
1 1 1
2 2 2
3 3 3
now i want max value of c2 column corresponding to values c1 column.
means for c1= 1 max c2 = 4
but we have two values for c1=1 and c2=4. here i want any of the two values..

so the final out put would look something like this -

C1 C2 C3
1 4 7
2 3 1
3 9 6

first I used select c1,c2,c3 from C where (c1,c2)in (select c1, max(c2) from C group by c1);

but i was getting the out put...
c1 C2 C3
1 4 7
1 4 9
2 3 1
3 9 6

here i want just one row corresponding to C1=1.

please giud me how should i proceed.

Jul 19 '10 #1
0 1308

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

Similar topics

by: John | last post by:
Why does a select from table with an integer field return a row if I compare the integer to an alpha character? Here's the info ( a straight copy and paste), then compare my two select statements: mysql> desc product; +------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+------+-----+---------+-------+
by: hubert.trzewik | last post by:
Hello, Is it possible to EXEC stored procedure from a query? I want to execute stored procedure for every line of SELECT result table. I guess it's possible with cursors, but maybe it's possible to make it easier. Give an example, please.
by: Botao | last post by:
Hi, Every Guru, I'd like to put a button on a page. When clicking the button, the table below it gets selected so the user can do Ctrl C to copy the entire table without using the mouse to select the table which can be big. How do I do it using javascript? I tried: <INPUT TYPE=Button NAME='Select' SIZE='10' VALUE='SelctTable' onClick="document.MyTable.select();">
by: saturnius | last post by:
Hello, I am passing a value to a stored procedure in vb.net to get normally a selection of the table. How could I get the complete table without writing the code twice? Many thanks in advance ....
by: Kall, Bruce A. | last post by:
I've look for a solution to this, but have only been able to find solutions to delete duplicate entries in a table by deleting entries not returned by SELECT DISTINCT. What sql should I use to SELECT entries in a table that have two particular column values that match? For example, my_table has name, phone number, identification_number, zip code, date of birth, and city
by: Eugene F | last post by:
I am trying to figure out a single select statement from a table function f(x) when the function's argument is fed from another result set, like SELECT ... FROM TABLE( f(x) ) a where x is a result set from another select (or subselect) as SELECT x FROM b Any idea?
by: pagoto123 | last post by:
select * from table where director = '" & Director.text & "' i want to display me all results that start with the director that the user will enter........ please i need the command help me ....! Yours sincerely GKpatakis
by: d0m_at0m | last post by:
hello, how to select a table that has a highest amount of columns (compared to other tables) using syscat? thanks in advance
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all On SQL Server tables I use SqlDataReader to query data like "SELECT * FROM table". Is there something similar for XML Files ? I want to use SQL Syntax like "SELECT * FROM table" on a XML file. After query I want to get something like SqlDataReader based on Query to loop. I do not want to use a DataSet. It should be more like streaming
by: onyris | last post by:
Hi have this query which works ok now : SELECT * FROM WHERE (((Table.published) Like '*'&!!& '*' And (Table.published) Like '*'&!!& '*' and (Table.address) Like '*'&!!& '*' )); and instead of using the default table which in this case is , i want to let the user to input which table the query to search on , and what i did is this
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.