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

Compare based on table values.

Rex
Hi

Below is a table with sample data to explain what I want to achieve.

trackID member marker
allele1
------- ------ --------------------------------------------------
-----------------------------------------------------
4734 4577 01-D8S1179 13.5
4734 4577 02-D21S11 12.6
4734 4577 03-D7S820 2.0
4734 4577 04-CSF1PO 3.0
4734 4577 06-TH01 4.0
4734 4577 07-D13S317 5.0
4734 4577 08-D16S539 9.0
4734 4577 11-vWA 6.0
4734 4577 12-TPOX 7.0
4734 4577 13-D18S51 1.0

4734 4578 01-D8S1179 13.0
4734 4578 02-D21S11 12.6
4734 4578 03-D7S820 2.0
4734 4578 04-CSF1PO 4.0
4734 4578 06-TH01 3.0
4734 4578 07-D13S317 5.0
4734 4578 08-D16S539 9.0
4734 4578 11-vWA 7.0
4734 4578 12-TPOX 6.0
4734 4578 13-D18S51 1.0

Okay I am trying to compare allele1 values for differences for two or
three different member having the same trackID. The list of markers
would always be same for all members belonging to a particular
trackID.

So in the above sample data. The trackID is same which is 4734. There
are two members 4577 and 4578. The markers are same for each members
but the corresponding allele1 values are different.

I want to compare these two and state whether they are same or not. I
would like to do this on a form containing subforms.

Feel free to ask for clarification.

Thank you.

Sep 10 '07 #1
2 1987
Rex wrote:
Below is a table with sample data to explain what I want to achieve.

trackID member marker
allele1
------- ------ --------------------------------------------------
-----------------------------------------------------
4734 4577 01-D8S1179 13.5
4734 4577 02-D21S11 12.6
4734 4577 03-D7S820 2.0
4734 4577 04-CSF1PO 3.0
4734 4577 06-TH01 4.0
4734 4577 07-D13S317 5.0
4734 4577 08-D16S539 9.0
4734 4577 11-vWA 6.0
4734 4577 12-TPOX 7.0
4734 4577 13-D18S51 1.0

4734 4578 01-D8S1179 13.0
4734 4578 02-D21S11 12.6
4734 4578 03-D7S820 2.0
4734 4578 04-CSF1PO 4.0
4734 4578 06-TH01 3.0
4734 4578 07-D13S317 5.0
4734 4578 08-D16S539 9.0
4734 4578 11-vWA 7.0
4734 4578 12-TPOX 6.0
4734 4578 13-D18S51 1.0

Okay I am trying to compare allele1 values for differences for two or
three different member having the same trackID. The list of markers
would always be same for all members belonging to a particular
trackID.

So in the above sample data. The trackID is same which is 4734. There
are two members 4577 and 4578. The markers are same for each members
but the corresponding allele1 values are different.
*scratches head* Oh, you mean that member 4577 has markers with values
(01-D8S1179, 02-D21S11, etc.) and member 4578 also has markers with
values (01-D8S1179, 02-D21S11, etc.).
I want to compare these two and state whether they are same or not.
select t1.trackID,
t1.member t1_member,
t2.member t2_member,
t1.marker,
t1.allele1 t1_allele1,
t2.allele1 t2_allele1
from the_table t1
join the_table t2 on t1.trackID = t2.trackID
and t1.member < t2.member
and t1.marker = t2.marker
and t1.allele1 <t2.allele1

This does not check for members missing one or more markers. You can
do that as follows:

select t1.trackID,
t1.member t1_member,
t2.member t2_member,
t1.marker
from the_table t1
join the_table t2 on t1.trackID = t2.trackID
and t1.member <t2.member
where t1.marker not in (
select marker
from the_table t3
where t3.trackID = t2.trackID
and t3.member = t2.member
)
I would like to do this on a form containing subforms.
Whut? Is this an Access thing? (Crystal Reports, my preferred
reporting layer, has reports containing subreports.)
Sep 10 '07 #2
Rex (ra*******@gmail.com) writes:
Below is a table with sample data to explain what I want to achieve.

trackID member marker
allele1
------- ------ --------------------------------------------------
-----------------------------------------------------
4734 4577 01-D8S1179 13.5
4734 4577 02-D21S11 12.6
4734 4577 03-D7S820 2.0
4734 4577 04-CSF1PO 3.0
4734 4577 06-TH01 4.0
4734 4577 07-D13S317 5.0
4734 4577 08-D16S539 9.0
4734 4577 11-vWA 6.0
4734 4577 12-TPOX 7.0
4734 4577 13-D18S51 1.0

4734 4578 01-D8S1179 13.0
4734 4578 02-D21S11 12.6
4734 4578 03-D7S820 2.0
4734 4578 04-CSF1PO 4.0
4734 4578 06-TH01 3.0
4734 4578 07-D13S317 5.0
4734 4578 08-D16S539 9.0
4734 4578 11-vWA 7.0
4734 4578 12-TPOX 6.0
4734 4578 13-D18S51 1.0

Okay I am trying to compare allele1 values for differences for two or
three different member having the same trackID. The list of markers
would always be same for all members belonging to a particular
trackID.

So in the above sample data. The trackID is same which is 4734. There
are two members 4577 and 4578. The markers are same for each members
but the corresponding allele1 values are different.

I want to compare these two and state whether they are same or not. I
would like to do this on a form containing subforms.
Don't really know where the form or the subform comes into the
picture. This is a group for a database engine. :-)

SELECT CASE WHEN EXISTS (SELECT 1
FROM tbl
WHERE member IN (@member1, @member2, @member3)
AND trackID = @trackID
GROUP BY marker
HAVING MIN(allelel) < MAX(allellel)
THEN 'There are difference'
ELSE 'All allellel are equal'
END

This is a bit of a guess, since it's not clear how you want the data.
For the future, a tip is that if you post:

o CREATE TABLE statement for your table.
o INSERT statements with sample data.
o The desired result given the sample.

Your odds for getting a tested query in respose are quite good.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Sep 10 '07 #3

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

Similar topics

5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
3
by: Mark | last post by:
I'm working with ASCII data files provided by data vendors in a standard format. These files contains lots of various pieces of information for each reporting entity in the file. Currently I...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
5
by: Jason | last post by:
Is there a mechanism in VB.NET that allows something like: If myVar In ("A","B","C") Then... The way I'm doing it now is: Select Case myVar Case "A","B","C" Or like this:
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
8
by: Tradeorganizer | last post by:
Hi, I have a database with table name as test in that i have 6 colums they are name varchar (20) address varchar (20) position varchar (20) nametype1 varchar (20) nametype2 varchar (20)
5
by: Edd E | last post by:
Hi, I have a database to store my analyses (Access 2002, WinXp), the basic structure is: TABLE 1 = Sample Info TABLE 2 = Analysis type 1 TABLE 3 = Analysis type 2 TABLE 4 = Analysis type 3 ...
2
by: pmelan | last post by:
Hi everyone. I wasn't sure how to describe what I want in the subject line so hopefully this post will allow me to further explain. I have a table where I have names of people who have filed...
3
by: mcolson | last post by:
I am trying to compare the last two values in the same column of a table. First of all, I have a column titled Row_Index that uses an index which starts at 1 and increments by 1. What I am trying...
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?
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
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...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.