Want to calculate the sum of the count rendered by group by option..
Posted
by Vijay
on Stack Overflow
See other posts from Stack Overflow
or by Vijay
Published on 2010-04-07T06:46:12Z
Indexed on
2010/04/07
6:53 UTC
Read the original article
Hit count: 225
i have a table with the columns such id, tid, companyid, ttype etc..
the id may be same for many companyid but unique within the companyid and tid is always unique and
i want to calculate the total no of transactions entered in the table,
a single transaction may be inserted in more than one row,
for example,
id tid companyid ttype
1 1 1 xxx
1 2 1 may be null
2 3 1 yyy
2 4 1 may be null
2 5 1 may be null
the above entries should be counted as only 2 transactions ..
it may be repeated for many companyids..
so how do i calculate the total no of transactions entered in the table
i tried
select sum(count(*)) from transaction group by id,companyId;
but doesn't work
select count(*) from transaction group by id;
wont work because the id may be repeated for different companyids.
© Stack Overflow or respective owner