View previous topic :: View next topic |
Author |
Message |
rajeeva Beginner
Joined: 14 Apr 2005 Posts: 1 Topics: 1
|
Posted: Mon Apr 18, 2005 2:57 am Post subject: DB2- Null value in GROUP BY Clause |
|
|
Hi,
I have the clarification regarding how the null values need to be appear after using Group by clause.
Example: Below shows the table containing the values
Code: |
DeptNumber DivisionCode SalesAmt
--------------- ------------------- -----------------
D1 DIV1 100
D1 DIV1 120
D1 DIV1 NULL
D2 DIV2 100
D2 DIV2 NULL
D2 DIV2 20
D3 DIV3 100
D3 DIV3 300
--------------------------------------------------------
|
What will be result after using GROUP BY clause ?
Code: |
SELECT DEPTNUMBER
,DIVISIONCODE
,AVG(SALESAMT)
FROM DEPTTABLE
GROUP BY DEPTNUMBER
,DIVISIONCODE
|
Please give the result after above SQL statement is executed.
Thanks and regards,
Rajeeva |
|
Back to top |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Mon Apr 18, 2005 3:27 am Post subject: |
|
|
Rajeeva,
Please don't post your question under an unrelated Topic.
Here is the answer to your question.
NULL values wouldn't be taken into consideration when calculating the Average. That row will be ignored when calculating the average.
So the result will be like
Code: |
DeptNumber DivisionCode SalesAmt
--------------- ------------------- -----------------
D1 DIV1 110
D2 DIV2 60
D3 DIV3 200
|
_________________ Cheers
Sivaraj S
'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity' |
|
Back to top |
|
 |
|
|