473,322 Members | 1,522 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,322 software developers and data experts.

Analytical function with where clause

My record set will look like this

ENAme -Part Time- Dept
qwe - Y - 10
fjj - N - 10
ghsd - N - 10

How to count using Analytical function count of parttime by dept
Ex :
dept 10 prttime - Y -count 1
dept 10 prttime - N -count 2

how to write select Statement ?
Sep 18 '06 #1
2 4944
select dept,partTime,count(*) from table_name group by dept,partime order by count(*)
Sep 19 '06 #2
The real power of analytical functions shows through when you want to see the full details of each record in the set along side totals and subtotals that you would normally have to calculate using a group by clause. Essentially analytical functions save you the trouble of joining the results of a group by query back to the original set of records that it was grouping.
A normal group by query as written by the first replier to your message would be simpler for getting the exact result set that you are requesting. But....
Say for instance you wanted to see the grouping count along side the full details (I changed the names to make them align better) like this...

AAA - Y - 10 - 1
BBB - N - 10 - 2
CCC - N - 10 - 2

For this you would write something like....

select a.*,
count() over (partition by Dept, Part time) as MemberCount
from
employees a
Oct 18 '06 #3

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

Similar topics

5
by: Yuri G. | last post by:
Hi, I'm trying to come up with a solution to seemingly simple database query, which I'm sure could be done with Oracle9 analytical functions, but somehow the solution is elusive: I have a...
6
by: Christian | last post by:
HI, I have a function that is used to constrain a query: Select COl1, Col2 From MyTable WHERE col1 = ... AND col2 = ... And MyFunction(col1) = ... My problem is that MyFunction is executed...
2
by: Agoston Bejo | last post by:
Version: Oracle 8.1.7. (I know it's prehistoric, but I am forced to work with it. Nevertheless, I'm curious if this is only a bug of this version or I'm wrong somewhere about SQL itself.) Take a...
1
by: Johm | last post by:
In my update clause using the NZ function, i would like to add a condition to exclude substracting from a Null.I do not want the NULL items to be included in the UPDATE, and then i will have to ...
20
by: Brian Tkatch | last post by:
An ORDER BY a simple-integer inside a FUNCTION, results in SQL0440N, unless the FUNCTION expects an INTEGER as its parameter. For example: DECLARE GLOBAL TEMPORARY TABLE A(A CHAR(1)) INSERT INTO...
2
by: ChasW | last post by:
I just read these 2 pages. These are most helpful, but leave me with a question. http://www.mvps.org/access/queries/qry0005.htm http://www.mvps.org/access/forms/frm0007.htm I have a Multi...
4
by: Phil Latio | last post by:
I'm kind of looking for some guidance in respect of this obstacle I'm up against - please let me expand; I have an option group with three options (AND, OR, & NONE) and a text box which will...
3
by: seenumahesh22 | last post by:
Hi, I have a doubt regarding a calculation by using analytical functions. ((1+r1)+(1+r2)+(1+r3)+....(1+r n) )*1000 where r1,r2,r3 are the values of a column in my table. I need to get the...
14
by: mesut | last post by:
hi colleagues, I don't know if this is the right group for but it's in C# so I try. I have a #3 procedural function called GetInfo.. and those are 3 overloaded methods. I would like to use the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.