473,804 Members | 3,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Analytical function with where clause

1 New Member
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 4962
imranpak
1 New Member
select dept,partTime,c ount(*) from table_name group by dept,partime order by count(*)
Sep 19 '06 #2
frethnkr1969
2 New Member
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
5992
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 table of the following structure: create table values ( ....
6
14679
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 as many times that there are
2
4432
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 look at this query: ----------------------- SELECT * FROM (
1
2341
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 add a WHERE clause to the SQL to exclude the NULLs. Im i right in principle, and if so, where should one place the where condition in my clause ? SQL = "UPDATE Products SET items = NZ(items,0) - " & Nz(Quantity, 0) & strWhere
20
2503
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 SESSION.A VALUES ('a'), ('b') CREATE FUNCTION A(A char(1)) RETURNS char(1) DETERMINISTIC NO EXTERNAL ACTION RETURN A SELECT A FROM SESSION.A ORDER BY A(1) DROP FUNCTION A DROP TABLE SESSION.A
2
2470
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 Select Listbox that will define query criteria for a query that is the record source for another form. Certain individual selections in this list box may act a label for a
4
2670
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 accept free text - the text will become criteria in a SQL string and depending upon the option the WHERE clause will be AND/OR LIKE textCriteria1 AND/OR LIKE textCriteria2.... I'm trying to create a VBA function to take the free text and break up...
3
1703
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 values like this first row (1+r1)*1000 secondrow ((1+r1)+(1+r2))*1000
14
1653
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 OOP approach to refactor this. The functions are working fine but I would like to have a OOP approach can someone help me refactoring this??????
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9150
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.