Display Record Counts [message #567273] |
Tue, 25 September 2012 21:37 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/654def26f5e651d3b55cc2bbda850403?s=64&d=mm&r=g) |
sr999
Messages: 1 Registered: September 2012
|
Junior Member |
|
|
Hi
I have a table
TAB1 with data
no name
1 abc
2 abc
3 xyz
4 xyz
5 cvb
now I would like to create a form with name counts as
abc 2
xyz 2
cvb 1
I would like to create a datablock to display all the unique names, not sure where I should be writing the query to display unique names. I would like to create a textitem box to display the counts when the form is compiled, but not sure which trigger to use to write the query.please help
|
|
|
Re: Display Record Counts [message #567282 is a reply to message #567273] |
Wed, 26 September 2012 02:56 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
The simplest way to do that is to create a view:
create view v_tab1 as
select name, count(*) cnt
from tab1
group by name and base your form's data block on that view.
[EDIT] Whoa! Forgot the GROUP BY clause! Thank you, @uzairawan, for pointing that out!
[Updated on: Tue, 02 October 2012 02:17] Report message to a moderator
|
|
|
Re: Display Record Counts [message #567486 is a reply to message #567282] |
Tue, 02 October 2012 02:11 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](//www.gravatar.com/avatar/f920a8c74a127a6e05e06acd631ee405?s=64&d=mm&r=g) |
uzairawan
Messages: 4 Registered: October 2012 Location: Pakistan
|
Junior Member |
|
|
This is a simple GROUP BY query by which you can retrieve aggregate SUM, COUNT and AVG of any numeric field. For example :
select deptno, count(empno) from emp
group by deptno
|
|
|