Home » Developer & Programmer » Forms » Display Record Counts (11g)
Display Record Counts [message #567273] Tue, 25 September 2012 21:37 Go to next message
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 messageGo to next message
Littlefoot
Messages: 21813
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
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

Previous Topic: Go Block Not Working
Next Topic: Strange error happening on some clients machines - WUO-708
Goto Forum:
  


Current Time: Thu Jul 04 16:02:20 CDT 2024