473,413 Members | 1,737 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.

Does count(sum()) function work in ibm iseries navigator ?

6
Consider an Employee table with columns employee id , employee name, salary, department name and department number.

We need to find “count” of the aggregate function, say sum of salary, grouped by department name and employee name !!!

The following query
"Select count(sum(salary)) from employee where ....(some condition) group by department name, employee name".
fails in IBM iseries navigator . Also I tried with inline views, sub queries, etc. ;but in vain;
Sep 25 '07 #1
1 4361
docdiesel
297 Expert 100+
Hi,

count(sum()) won't work, like this example with sysibm.sydummy1 shows:

Expand|Select|Wrap|Line Numbers
  1.  db2 "select sum(7) from sysibm.sysdummy1"
  2. 1
  3. -----------
  4.           7
  5.   1 record(s) selected.
  6.  
  7. db2svc01@iona:~> db2 "select count(sum(7)) from sysibm.sysdummy1"
  8. SQL0112N  The operand of the column function "COUNT" includes a column
  9. function, a scalar fullselect, or a subquery.  SQLSTATE=42607
SUM() always returns a number, so its count would be 1. I'm not quiet sure if I understand your needs correctly, but I think you don't need to count the sums but the departments. So you might need something like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT  department, sum(salary), count(distinct employee)
  2. FROM    myschema.myemployees
  3. GROUPED BY department
Regards, Bernd
Sep 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: | last post by:
>>> def f(y): ... return ... >>> f(3) , , 1, 1, 3, 3] >>> I've been staring at it for 15 minutes and I'm no closer to understanding than when I started. Why is this even legal Python...
2
by: Vincent van Beveren | last post by:
I have the following (seemingly) useless piece of JavaScript <html> <head> <script type="text/javascript"> function frameMe() { s = "document.open();"; s +=...
9
by: chandramohan.mani | last post by:
Does Event handlers work in netscape. If yes means can anyone please help me. <HTML><SCRIPT LANGUAGE="JScript"> function mouseclick() { alert("I was clicked on " +...
16
by: Geoff Cox | last post by:
Hello, Can someone please explain how this preload images function works? It is the picture.onload = preload_imgs; which I don't understand.
12
by: Frank Hauptlorenz | last post by:
Hello Out there! I have a DB2 V7.2 Database (Fix11) on Win 2000 Professional. It was before a NT 4 based Domain - now it is a Win 2000 Domain. The database server is a domain member. Now...
0
by: PASQUALE | last post by:
Hi, I am new to DB2 on AS/400. Actually I use the 'Run SQL Scripts' - tool in iSeries Navigator to access the database by SQL. The question is: Is there an alternative (or maybe better) tool for...
4
by: titan nyquist | last post by:
Why does ToTitleCase not work if the case is already in upper case? I have to make my string lowercase, first, before I pass to to ToTitleCase to have it work. Titan
3
by: driss | last post by:
HOW DOES STRCPY WORKS ? why do we need it ?
3
by: xmail123 | last post by:
Why does this code work? I am new to C# and have been studying this piece of code. It loops through an Adjacency Matrix table to populate a tree view. I have two questions about why this code...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.