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

Comparison of two rows in a table using SQL ?

Hi,

Can anybody tell me how to compare two rows in a single tablle using SQL ?
Jun 20 '07 #1
3 6787
Hi,

Can anybody tell me how to compare two rows in a single tablle using SQL ?
Try Self joins

eg: Select * from Table1 A, Table1 B
where (conditions )
Jun 22 '07 #2
Hi ,

Below is a sample data of the table.

IBPSUB IBPQTN CLIENT_INFORMATION CLASS ASSESTS
18783 1 Echo Test 1 - Client A 730 100000
18783 2 Echo Test 1 - Client A 730 120000
18784 1 Echo Test 1 - Client B 853 130000
18785 1 Echo Test 1 - Client C 853 100000
18785 81 Echo Test 1 - Client C 854 100000


Primary keys : IBPSUB and IBPQTN

My problem is : Whenever a Record having a particular IBPSUB has a IBPQTN number = 80 + IBPQTN , then I will have display the only record having greater IBPQTN value ..


My expected output from above table should be :

IBPSUB IBPQTN CLIENT_INFORMATION CLASS ASSESTS
18783 1 Echo Test 1 - Client A 730 100000
18783 2 Echo Test 1 - Client A 730 120000
18784 1 Echo Test 1 - Client B 853 130000
18785 81 Echo Test 1 - Client C 854 100000

IBPSUB 18785 has IBPQTN #1 and 81 ... since this IBPSUB had 1 and 81 in problem so the result should display only 81 not 1.

That's my problem ..

Please help me

Thanks
Jun 23 '07 #3
What you need is a query with correlated subquery using Max:

Select *
from table1 a
where IBPQTN =
(select max(IBPQTN)
from table1 b
where a.IBPSUB = b.IBPSUB)
Jun 27 '07 #4

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

Similar topics

5
by: Shay | last post by:
essentially I am trying to do some counts based on some assumptions in the recordset. So I get the RS back, put the values into a variable, move to the next record in the RS and compare what is in...
133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
11
by: csomberg | last post by:
SQL Server 2000 I will to compare a normal table with a replicated audit table having identical columns. I wish to report on the differences between the data. How can I loop though a "column...
0
by: Tim Brooks | last post by:
All, I'm hoping one of you Xml or Data gurus can offer an opinion. I'm working on an app to basically compare two semi-structured data files (e.g. Excel / CSV) to one another. But I need to...
1
by: Thats Me | last post by:
TMALSS: Task With maintenance of Access Database I did not develop, don't ask about non-commented code problems or where data dictionary is (LOL). Have table with Inventory data for all...
5
by: Tara via AccessMonster.com | last post by:
Hi there - I'll do my best to explain my dilema. I'm using Access 2000. In this database, there is one table with about 150 columns of information, and 206 rows. There are numerous queries and...
7
by: matt | last post by:
hello, i have been given a challenging project at my org. i work on an inventory management web application -- keeping tracking of parts assigned to projects. in the past, i built an in-house...
13
by: SQL Learner | last post by:
Hi, I have a table with 8 millions records. Some of the fields needed to be parse and modified. Example, "ABC DEF" will be parsed into two fields "ABC" and "DEF". And If there is "123" in the...
1
Eep˛
by: Eep˛ | last post by:
My 3D game comparison table is currently done without a database and is just a big complicated table (which I'd like to get sortable but the sortable Javascript I currently use can't handle the table...
3
by: DragonLord | last post by:
Here is the situation I am inserting rows into a datagridview and then using a function to group similar rows together based on a column. When I call to compare the lastrow with the current row...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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
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
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
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...

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.