473,395 Members | 1,530 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.

complex query

Hi all,
i am new to sql. Could anyone help me find a solution to this
problem.
I have a table with 3 fields like this,

test_name varchar(25) primary key
test_result varchar(10)
test_level integer primary key

my data looks like
test1,pass,1
test1,fail,2

test2,pass,1
test2,pass,2

test3,pass,1
test3,fail,2

test4,fail,2
test4,fail,3
the assumption is that all the test should have same status (no matter
pass or fail) in all the test_level.
my query should output the "test_name" which has different results in
different test_level.
In the above example data, test1 passed in level 1 and failed in 2
i want to catch this data.

FYI, I am using MySql.
Thanks in advance,
Sasi
Jul 19 '05 #1
4 2684
BDR
Your question is more complex than the query... hmm, not exactly sure
what you're after.
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test
GROUP BY test_name
will give you:

test1 1 pass
test2 2 pass
test3 1 pass
test4 2 fail
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test WHERE
test_result='fail' GROUP BY test_name
will give you:

test1 2 fail
test2 2 fail
test3 2 fail
test4 2 fail
---------------------------------------------------------
SELECT test_level, test_name, test_result FROM test WHERE
test_result='fail' GROUP BY test_level
will give you:

2 test2 fail
3 test4 fail
---------------------------------------------------------

Lots of different ways to `catch` data :-) ... The confusing part is
that you said all the test should have the same status no matter pass or
fail. What do you mean `same status`? You want'em all like together or
something or??

..... snip ....
the assumption is that all the test should have same status (no matter
pass or fail) in all the test_level.
my query should output the "test_name" which has different results in
different test_level.
In the above example data, test1 passed in level 1 and failed in 2
i want to catch this data.

FYI, I am using MySql.
Thanks in advance,
Sasi


Jul 19 '05 #2
BDR
Your question is more complex than the query... hmm, not exactly sure
what you're after.
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test
GROUP BY test_name
will give you:

test1 1 pass
test2 2 pass
test3 1 pass
test4 2 fail
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test WHERE
test_result='fail' GROUP BY test_name
will give you:

test1 2 fail
test2 2 fail
test3 2 fail
test4 2 fail
---------------------------------------------------------
SELECT test_level, test_name, test_result FROM test WHERE
test_result='fail' GROUP BY test_level
will give you:

2 test2 fail
3 test4 fail
---------------------------------------------------------

Lots of different ways to `catch` data :-) ... The confusing part is
that you said all the test should have the same status no matter pass or
fail. What do you mean `same status`? You want'em all like together or
something or??

..... snip ....
the assumption is that all the test should have same status (no matter
pass or fail) in all the test_level.
my query should output the "test_name" which has different results in
different test_level.
In the above example data, test1 passed in level 1 and failed in 2
i want to catch this data.

FYI, I am using MySql.
Thanks in advance,
Sasi


Jul 19 '05 #3
thank you very much for your reply & sorry for my bad english.
let me put it in this way,

The field "test_name" is not unique, So I can have same test name more
than once in my data,
eg: let say my data looks like this (test_name,test_level,test_result)

test1,1,pass
test1,2,fail

test2,1,pass
test2,2,pass

test3,1,fail
test3,2,fail

in the above example,
"test2" & "test3" have same "test_result" for all "test_level"
but "test1" have different "test_result" on different "test_level" , I
need catch this information.
i.e., i have get the test_name if my "test_result" are different for
different "test_level"

Hope this will be bit clear,
Thanks
Sasi


BDR <jo*@noemail.com> wrote in message news:<3F**************@noemail.com>...
Your question is more complex than the query... hmm, not exactly sure
what you're after.
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test
GROUP BY test_name
will give you:

test1 1 pass
test2 2 pass
test3 1 pass
test4 2 fail
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test WHERE
test_result='fail' GROUP BY test_name
will give you:

test1 2 fail
test2 2 fail
test3 2 fail
test4 2 fail
---------------------------------------------------------
SELECT test_level, test_name, test_result FROM test WHERE
test_result='fail' GROUP BY test_level
will give you:

2 test2 fail
3 test4 fail
---------------------------------------------------------

Lots of different ways to `catch` data :-) ... The confusing part is
that you said all the test should have the same status no matter pass or
fail. What do you mean `same status`? You want'em all like together or
something or??

.... snip ....
the assumption is that all the test should have same status (no matter
pass or fail) in all the test_level.
my query should output the "test_name" which has different results in
different test_level.
In the above example data, test1 passed in level 1 and failed in 2
i want to catch this data.

FYI, I am using MySql.
Thanks in advance,
Sasi

Jul 19 '05 #4
thank you very much for your reply & sorry for my bad english.
let me put it in this way,

The field "test_name" is not unique, So I can have same test name more
than once in my data,
eg: let say my data looks like this (test_name,test_level,test_result)

test1,1,pass
test1,2,fail

test2,1,pass
test2,2,pass

test3,1,fail
test3,2,fail

in the above example,
"test2" & "test3" have same "test_result" for all "test_level"
but "test1" have different "test_result" on different "test_level" , I
need catch this information.
i.e., i have get the test_name if my "test_result" are different for
different "test_level"

Hope this will be bit clear,
Thanks
Sasi


BDR <jo*@noemail.com> wrote in message news:<3F**************@noemail.com>...
Your question is more complex than the query... hmm, not exactly sure
what you're after.
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test
GROUP BY test_name
will give you:

test1 1 pass
test2 2 pass
test3 1 pass
test4 2 fail
---------------------------------------------------------
SELECT test_name, test_level, test_result FROM test WHERE
test_result='fail' GROUP BY test_name
will give you:

test1 2 fail
test2 2 fail
test3 2 fail
test4 2 fail
---------------------------------------------------------
SELECT test_level, test_name, test_result FROM test WHERE
test_result='fail' GROUP BY test_level
will give you:

2 test2 fail
3 test4 fail
---------------------------------------------------------

Lots of different ways to `catch` data :-) ... The confusing part is
that you said all the test should have the same status no matter pass or
fail. What do you mean `same status`? You want'em all like together or
something or??

.... snip ....
the assumption is that all the test should have same status (no matter
pass or fail) in all the test_level.
my query should output the "test_name" which has different results in
different test_level.
In the above example data, test1 passed in level 1 and failed in 2
i want to catch this data.

FYI, I am using MySql.
Thanks in advance,
Sasi

Jul 19 '05 #5

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

Similar topics

4
by: Starbuck | last post by:
OK, first let me say that I am no DB person. But I have a user here who keeps getting this error whenever she does, whatever it is she does, with databases... A google search takes me to...
2
by: Mikel | last post by:
I am trying to get around the problem "The expression you have entered is too complex" for a select query. (The example below is not the expression that is giving me headaches.) So I am thinking...
4
by: ED | last post by:
I am attempting to to write a query that has a numerous nested IIf statements. The problem that I am having is that it is to long of a query to be built in design mode and when I build it in sql...
8
by: Matt | last post by:
Hi all, Thank you for taking the time. I have a database with 45 tables on it. 44 tables are linked to a main table through a one to one relationship. My question is, is there no way i can...
2
by: Ben de Vette | last post by:
Hi, I'm using the querybuilder when updating a record in a table (Access). However, I get a "Query is too complex" message. The Primary key is autonumbered. Why is it making such a complex...
1
by: arun | last post by:
Query is too complex -------------------------------------------------------------------------------- Hi, I was trying to solve this problem since last two days but couldn't find any solution. ...
1
by: Randy Volkart | last post by:
I'm trying to fix a glitch in a complex access database, and have a fairly complex problem... unless there's some obscure easy fix I don't know being fairly new with Access. Basically, the area...
19
by: kawaks40 | last post by:
Hi everyone :) I just recently started using access/sql. and right away I ran into this problem "SQL expression too complex" I google'd a lot on what it means, and the only workaround I've...
3
by: Eric Davidson | last post by:
DB2 9.5 I keep geting the message. SQL0101N The statement is too long or too complex. SQLSTATE=54001 When one of my sql statements takes over 60 seconds to compile the sql statement. Is...
0
crystal2005
by: crystal2005 | last post by:
Hi, I am having trouble with some complex SQL queries. I’ve got winestore database, taken from Web Database Application with PHP and MySQL book. And some question about queries as the following ...
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: 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
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
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
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,...

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.