Tuesday, December 29, 2020

mySQL: Basic aggregates from a table

In mySQL, how do I get the basic aggregates from a table? 



mySQLExplanationSQL Server
use enron;
select COUNT(*) as counted from recipientinfo;
select MIN(rid) as rid_min from recipientinfo;
select MAX(rid) as rid_max from recipientinfo;
select SUM(rid/10.0) as rid_summed from recipientinfo;
select AVG(rid/10.0) as rid_avgd from recipientinfo;
No real surprises here - they work the same in both places. use Enron;
go
select COUNT(*) as counted from dbo.recipientinfo;
select MIN(rid) as rid_min from dbo.recipientinfo;
select MAX(rid) as rid_max from dbo.recipientinfo;
select SUM(rid/10.0) as rid_summed from dbo.recipientinfo;
select AVG(rid/10.0) as rid_avgd from dbo.recipientinfo;

No comments:

Post a Comment