hi I have the data in sql server table like
OrderID Trans ID
74 1
74 4
74 5
76 1
76 4
76 5
here please observe TransID 1,4,5 is repeating in all the orderID
Field.In my table some of the order's have the value "1" but not have
"5".We need to find the orders id's which are having 1 for that order
id and not having the value 5.Please send me a query for this
Thanks,
Srui 6 2804
srinivas wrote: hi I have the data in sql server table like
OrderID Trans ID 74 1 74 4 74 5 76 1 76 4 76 5
here please observe TransID 1,4,5 is repeating in all the orderID Field.
Pardon?
In my table some of the order's have the value "1" but not have "5".We need to find the orders id's which are having 1 for that order id and not having the value 5.Please send me a query for this
Wrong newsgroup.
However, the condition "value '1' and not value '5'" contains a redundancy.
What is 1 is always not 5:
SELECT OrderID FROM a WHERE 'Trans ID' = 1 GROUP BY 1
Maybe you mean "value 1 _or_ not 5":
SELECT OrderID FROM a WHERE 'Trans ID' != 5 GROUP BY 1
PointedEars
Thomas 'PointedEars' Lahn said the following on 12/26/2005 3:26 PM: srinivas wrote:
hi I have the data in sql server table like
OrderID Trans ID 74 1 74 4 74 5 76 1 76 4 76 5
here please observe TransID 1,4,5 is repeating in all the orderID Field.
Pardon?
In my table some of the order's have the value "1" but not have "5".We need to find the orders id's which are having 1 for that order id and not having the value 5.Please send me a query for this
Wrong newsgroup.
However, the condition "value '1' and not value '5'" contains a redundancy. What is 1 is always not 5:
SELECT OrderID FROM a WHERE 'Trans ID' = 1 GROUP BY 1
Maybe you mean "value 1 _or_ not 5":
No, it reads "value 1 _and_ not 5".
OrderID 74 has three Trans ID's, 1, 4 and 5.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote: Thomas 'PointedEars' Lahn said the following on 12/26/2005 3:26 PM: However, the condition "value '1' and not value '5'" contains a redundancy. What is 1 is always not 5:
SELECT OrderID FROM a WHERE 'Trans ID' = 1 GROUP BY 1
Maybe you mean "value 1 _or_ not 5": No, it reads "value 1 _and_ not 5".
The condition
'Trans ID' = 1 AND 'Trans ID' != 5
contains a redundancy because everything that is equal to 1 is always
not equal to 5. So that condition does not really make sense. Instead,
an OR makes more sense, for the query result would contain _additional_
data then (hence the misuse/non-logical use of "and").
OrderID 74 has three Trans ID's, 1, 4 and 5.
So? Either query I provided will return those ...
PointedEars
Thomas 'PointedEars' Lahn said the following on 12/26/2005 5:17 PM: Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 12/26/2005 3:26 PM:
However, the condition "value '1' and not value '5'" contains a redundancy. What is 1 is always not 5:
SELECT OrderID FROM a WHERE 'Trans ID' = 1 GROUP BY 1
Maybe you mean "value 1 _or_ not 5": No, it reads "value 1 _and_ not 5".
The condition
'Trans ID' = 1 AND 'Trans ID' != 5
contains a redundancy because everything that is equal to 1 is always not equal to 5.
Not when the item has multiple Trans ID's which is what the posted data
shows:
OrderID Trans ID
74 1
74 4
74 5
So, if OrderID # 80 looked like this:
OrderID Trans ID
80 1
80 4
Then 80 should qualify as it contains 1 but does not have a Trans ID of
5. But orderID # 74 shouldn't qualify as it has 1 but also has 5.
It is the same scenario as if OrderID was a FlightNum and TransID was
layover sites on a plane flight. If you want all the flights from New
York to Moscow that do not layover in London but do layover in Paris
then its "Yes London AND Not Paris".
So that condition does not really make sense.
Sure it does. Re-read it though.
Instead, an OR makes more sense, for the query result would contain _additional_ data then (hence the misuse/non-logical use of "and").
The OP is wanting to minimize data, not have additional data. OrderID 74 has three Trans ID's, 1, 4 and 5.
So? Either query I provided will return those ...
Since this is a javascript group, I won't comment on potential SQL queries.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote: Thomas 'PointedEars' Lahn said the following on 12/26/2005 5:17 PM: Randy Webb wrote:Thomas 'PointedEars' Lahn said the following on 12/26/2005 3:26 PM: However, the condition "value '1' and not value '5'" contains a redundancy. What is 1 is always not 5:
SELECT OrderID FROM a WHERE 'Trans ID' = 1 GROUP BY 1
Maybe you mean "value 1 _or_ not 5": No, it reads "value 1 _and_ not 5".
The condition
'Trans ID' = 1 AND 'Trans ID' != 5
contains a redundancy because everything that is equal to 1 is always not equal to 5.
Not when the item has multiple Trans ID's which is what the posted data shows:
OrderID Trans ID 74 1 74 4 74 5
So, if OrderID # 80 looked like this:
OrderID Trans ID 80 1 80 4
Then 80 should qualify as it contains 1 but does not have a Trans ID of 5. But orderID # 74 shouldn't qualify as it has 1 but also has 5.
SELECT DISTINCT OrderID FROM trans WHERE Trans_ID = 1 AND OrderID
NOT IN (SELECT DISTINCT OrderID FROM trans WHERE Trans_ID = 5); OrderID 74 has three Trans ID's, 1, 4 and 5. So? Either query I provided will return those ...
Since this is a javascript group, I won't comment on potential SQL queries.
Since I have tested successfully this in MySQL Ver 14.12 Distrib 5.0.16:
X-Post & Followup-To comp.databases.mysql
PointedEars
srinivas a écrit : hi I have the data in sql server table like
OrderID Trans ID 74 1 74 4 74 5 76 1 76 4 76 5
here please observe TransID 1,4,5 is repeating in all the orderID Field.In my table some of the order's have the value "1" but not have "5".We need to find the orders id's which are having 1 for that order id and not having the value 5.Please send me a query for this
Thanks, Srui
Bonjour,
try :
select A.OrderId from Table A
where A.TransID=1 and A.OrderID not in (Select B.OrderID from Table B
where B.TransID=5 )
(and respect type of data)
GR This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve |
last post by:
I just spent waaaaaaaaaaaayy too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone
can explain to me why it was reported that way.
...
|
by: Andreas Lauffer |
last post by:
I changed from Access97 to AccessXP and I have immense performance
problems.
Details:
- Access XP MDB with Jet 4.0 ( no ADP-Project )
- Linked Tables to SQL-Server 2000 over ODBC
I used...
|
by: Matt |
last post by:
Hello
I am running a SP from the SQL Server Agent, the job has one step that
looks like this.
exec q_spr_inlevextsystem
This job fails with the following message
Job 'AutoInlev' : Step...
|
by: Rick Caborn |
last post by:
Does anyone know of a way to execute sql code from a dynamically built
text field?
Before beginning, let me state that I know this db architecture is
built solely for frustration and I hope to...
|
by: Christine |
last post by:
It has come to my attention that sometimes, when I open a Query in SQL
View, the SQL that I see is not exactly the same as the SQL in the
Query's Querydef. The difference I see (only occasionally)...
|
by: Tony Epton |
last post by:
I am not quite a newbie in the area of SQL server - more "knows just
enough to be dangerous"
- so please be gentle with me.
Cross posted to several groups - apologies if too far off topic
I...
|
by: Martini |
last post by:
Hello all.
I have quite disturbing situation where I am not happy about the way how SQL
handles the query. Situation is related to using user function in INNER JOIN
select. Although the problem...
|
by: Fuzzydave |
last post by:
I am back developing futher our Python/CGI based web application run by
a Postgres DB
and as per usual I am having some issues. It Involves a lot of Legacy
code. All the actual
SQL Querys are...
|
by: Twobridge |
last post by:
I hope someone can help me out with my problem.
I have found a sql statement that basically pulls all bills filed
within a
certain time period and the payments made on those bills with in the...
|
by: HC |
last post by:
Hello, all, I started out thinking my problems were elsewhere but as I
have worked through this I have isolated my problem, currently, as a
difference between MSDE and SQL Express 2005 (I'll just...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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,...
|
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...
| |