SQLite Forum

(Deleted)
Login

(1) By ThanksRyan on 2021-07-12 23:58:58 [source]

Hi all,

Previous answer from Keith: forumpost:f75c5.

The value 82793601.0 is from a different table that I've now imported into SQLIte and I'd like to know how to calculate it within sqlite, but the two tables don't have the same schema. Some data is shared among it, but the column names are different.

I don't know what kind of join I need but I know this doesn't work.

select
	counts,
	xz_in,
	zy_out,
	(zy + PW) / coin_in * 100.0 as POP
from (
	select
	count(e.IDRecord) as counts,
	sum(e.wager) as xz_in,
	sum(e.zy) as zy_out,
	sum(cg.ClaimAmt) as PW
from
	table1 as e
join cg on
	e.count = cg.winRecordId
)

The result:

414919861,103729965250,93239178150,9700.0

Should actually be:

4342056,1085514000,976264100,94.0102679467976

(976264100 + 44230520) / 1085514000 * 100

Note: 82793601.0 was the value in the previous post, but there's now a new value and it's correct above, 976264100.