Written By:- Isha Malhotra
Our Website:-Tech Altum
Our Website:-Tech Altum
Compute
and Compute By
Sometimes in your records you need to show
all data of table with some aggregate.
For
example:-
See the data of following table:-
Figure 1
Suppose I want to show the data of all columns
and after that I want to show the count of gender.
In this situation we will use the compute
in following way:-
select
* from Enqdata
compute count(gender)
the output of this query will be as
follows:-
Figure 2
If first shows all records and after that
it shows aggregate which I applied on gender ( i.e count)
When we want to show data according to particular
column, in this case we use compute by in following manner:-
select
* from Enqdata
order
by(gender)
compute count(gender) by gender
the output of this query is as
follow:-
Figure 3
Note:-order by is must for compute by.
No comments:
Post a Comment