How to include a custom field (sum) as a column

Hi guys,

I am a new user to Metabase and so far I like it a lot.
But I am wondering if it is possible to do the following:

I am using a SQLite database, and there is a column in a table called recv,
there is also a timestamp field, and some other text-based fields.

What I would like to achieve is:

  1. either to include a new column in the table (raw data) that has a value of sum(recv)
  2. or to include a new column in the table (raw data) that has a value of recv/sum(recv)

Even when I do a custom SQL expression like:
SELECT "peer_cc_stats"."recv"/sum("peer_cc_stats"."recv") AS "recv_ratio", ...

the result set for a weird reason is 1 row (?)

Could you please advise on how to achieve this ?

Hi,

Did you ever figure this out as I’m trying to do the exact same thing!

Thanks,

@priwding Depending on which database you’re querying, there’s several options, but you’ll likely find better help in a forum dedicated to your database:
https://stackoverflow.com/questions/19802556/sql-percentage-of-total-rows