BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

weird SQL result set from 2 similar SQL statement

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
yichun
Guest





PostPosted: Mon Aug 30, 2004 10:42 am    Post subject: weird SQL result set from 2 similar SQL statement Reply with quote



hi,
i am a novice in ORACLE. i am using Oracle 8i.

i have two similar query, actually they should generate result sets but one
of them did not:
query1:(empty result set)
SELECT COL1, COL2, SUM(COL3) FROM TABLE1
GROUP BY COL1, COL2

query2:(got result set)
SELECT COL1, SUM(COL3) FROM TABLE1
GROUP BY COL1

if i exclude COL2 in query1(become query2), it have result set!

if COL2 did not contain any null data, what the reason is query1 doesnot
have result set?
Is oracle data corrupted?


Back to top
Eric Hill
Guest





PostPosted: Mon Aug 30, 2004 1:19 pm    Post subject: Re: weird SQL result set from 2 similar SQL statement Reply with quote



Quote:
i am a novice in ORACLE. i am using Oracle 8i.

Welcome

Quote:
if COL2 did not contain any null data, what the reason is query1 doesnot
have result set?

You probably have null data in COL3, not COL2. Summing values that include null returns no result
since you can't sum a null value. Add "where col3 is not null" to the end of the first query and
see if that helps.

Quote:
Is oracle data corrupted?

I'd doubt it :)

Eric



Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Mon Aug 30, 2004 5:05 pm    Post subject: Re: weird SQL result set from 2 similar SQL statement Reply with quote



Eric Hill wrote:
Quote:

You probably have null data in COL3, not COL2. Summing values that
include null returns no result since you can't sum a null value. Add
"where col3 is not null" to the end of the first query and see if
that helps.

But he's summing COL3 in both cases, only omiting COL2 from the grouping.
Definitely something strange, he should get *different* results, but not an
empty result in one while not the other.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"True peace is not the absence of tension, but the presence of
justice." - Martin Luther King, Jr.



Back to top
Eric Hill
Guest





PostPosted: Mon Aug 30, 2004 6:29 pm    Post subject: Re: weird SQL result set from 2 similar SQL statement Reply with quote

Quote:
But he's summing COL3 in both cases, only omiting COL2 from the grouping.
Definitely something strange, he should get *different* results, but not an
empty result in one while not the other.

Yup, you're right. I went back and ran a test and it worked as expected.

Have you tried metalink? Maybe there's some bug in 8 that you're running into...

Eric



Back to top
yichun
Guest





PostPosted: Tue Aug 31, 2004 2:52 am    Post subject: Re: weird SQL result set from 2 similar SQL statement Reply with quote

sorry, what is metalink.

"Eric Hill" <eric (AT) ijack (DOT) net> wrote

Quote:
But he's summing COL3 in both cases, only omiting COL2 from the
grouping.
Definitely something strange, he should get *different* results, but not
an
empty result in one while not the other.

Yup, you're right. I went back and ran a test and it worked as expected.

Have you tried metalink? Maybe there's some bug in 8 that you're running
into...

Eric





Back to top
Eric Hill
Guest





PostPosted: Tue Aug 31, 2004 4:22 am    Post subject: Re: weird SQL result set from 2 similar SQL statement Reply with quote

http://metalink.oracle.com

It's Oracle's complete knowledge base.

Eric


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.