Home » Developer & Programmer » Forms » Display Record Counts (11g)
Display Record Counts [message #567273] Tue, 25 September 2012 21:37 Go to next message
Messages: 1
Registered: September 2012
Karma: 0
Junior Member
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 messageGo to next message
Messages: 21148
Registered: June 2005
Location: Croatia, Europe
Karma: 0
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
Messages: 4
Registered: October 2012
Location: Pakistan
Karma: 0
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

Previous Topic: Webutil libraries problem
Next Topic: Icons Not Showing on buttons
Goto Forum:

Current Time: Tue Aug 22 10:06:57 CDT 2017

Total time taken to generate the page: 0.07311 seconds