Creating a view that shows the balance of accounts on every day, when the "balance" table only has entries on
Date : March 29 2020, 07:55 AM
this will help It would be easier to provide more correct query, if you'll provide description for tables and some sample data. However, I think this query would work - it'll return the closest to given date row from BALANCE: SELECT * FROM DATES d, BALANCE b
WHERE d.date >= b.date
AND b.date >= ALL (SELECT b1.date FROM BALANCE b1
WHERE b1.date <= d.date
AND b1.account = b.account)
SELECT d.date, b.account, b.balance FROM DATES d, BALANCE b
WHERE d.date >= b.date
AND b.date >= ALL (SELECT b1.date FROM BALANCE b1
WHERE b.account = b1.account
AND d.date >= b1.date)
ORDER BY d.date, b.account
|
Create Trial Balance via Sql in MySql
Tag : mysql , By : negonicrac
Date : November 14 2020, 05:16 PM
hope this fix your issue You could achieve that result with a select over a union of two queries, one for the month to date and one for the year to date figures. select accno, accopbal, sum(mtd_d), sum(mtd_c), sum(ytd_d),sum(ytd_c)
from
( select ao.accno
, ao.accOpBal
, 0 as mtd_d
, 0 as mtd_c
, 0 as ytd_d
, 0 as ytd_c
from accounts ao
left outer join transactions tn on tn.accno = ao.accno
where tn.accno is null
union
select tm.accno
, a.accOpBal
, sum(tm.transdebit) as mtd_d
, sum(tm.transcredit) as mtd_c
, 0 as ytd_d
, 0 as ytd_c
from accounts a
right outer join transactions tm on tm.accno = a.accno
where tm.transdt between '2014-01-01' and '2014-01-31'
group by a.accno, a.accopbal
union
select ty.accno
, a.accOpBal
, 0
, 0
, sum(ty.transdebit)
, sum(ty.transcredit)
from accounts a
right outer join transactions ty on ty.accno = a.accno
and ty.transdt between '2013-07-01' and '2014-01-31'
group by a.accno, a.accopbal
) alltxn
group by accno, accopbal
-- january
insert into transactions values (1, 'alfki', '2014-01-01', 1,3);
insert into transactions values (1, 'alfki', '2014-01-02', 1,3);
insert into transactions values (1, 'alfki', '2014-01-03', 1,3);
-- last year
insert into transactions values (1, 'alfki', '2013-09-01', 5,2);
-- txn without acc
insert into transactions values (1, 'noexi', '2014-01-03', 4,2);
-- acc with txn
INSERT INTO Accounts values ( 'alfki', 'alfred', 4);
-- acc without txn
INSERT INTO Accounts values ( 'lefto', 'lefto', 6);
ACCNO | ACCOPBAL |SUM(MTD_D)|SUM(MTD_C)|SUM(YTD_D)|SUM(YTD_C)
------+----------+----------+----------+----------+-----------
alfki | 4 | 3 | 9 | 8 | 11
lefto | 6 | 0 | 0 | 0 | 0
noexi | (null) | 4 | 2 | 4 | 2
|
PHP/MySQL Multidimensional/Associative Arrays 3 Trial Balance
Date : March 29 2020, 07:55 AM
This might help you Ok (I should've paid more concentration during those accounts lectures). Now I don't know if an account (except Bank and Cash) can have debit and credit at the same time, but since your example entries didn't indicate, I'm guessing it doesn't. Also, the below code assumes (like indicated in the comment above) that you have a column (I named it transaction) which says whether it's a Dr or Cr entry. //this array will hold bank and cash values
$main_acc=array('bank'=>array('Dr'=>0,'Cr'=>0), 'cash'=>array('Dr'=>0,'Cr'=>0));
//this one to hold other accounts and their amounts, transaction etc.
$acc = array();
while($rowin = mysqli_fetch_array($rein, MYSQLI_ASSOC)) {
/* store bank transaction type and amount */
if($rowin['paymode']=='Cheque'){
$main_acc['bank'][$rowin['transaction']] =$main_acc['bank'][$rowin['transaction']] + $rowin['amount'];
}
/* store cash transaction type and amount */
if($rowin['paymode']=='Cash'){
$main_acc['cash'][$rowin['transaction']] = $main_acc['cash'][$rowin['transaction']] + $rowin['amount'];
}
/* store other account transaction type and increment
amount if already exists */
if(isset($acc[$rowin['account']])){
$acc[$rowin['account']]['amount'] = $acc[$rowin['account']]['amount'] +$rowin['amount'];
}
else
{
$acc[$rowin['account']]['trans'] = $rowin['transaction'];
$acc[$rowin['account']]['amount'] = $rowin['amount'];
}
}
echo '
<table>
<tr>
<td align="left"><b>ACCOUNT</b></td>
<td align="right"><b>DEBIT</b></td>
<td align="right"><b>CREDIT</b></td>
</tr>
';
$bg = '#eeeeee';
//displaying bank and cash
foreach($main_acc as $key=>$val){
$bg = ($bg=='#eeeeee') ? '#ffffff' : '#eeeeee';
echo '<tr bgcolor="'. $bg .'">
<td align="left">'. $key .'</td>
<td align="left">'. (($val['Cr']!=0)?$val['Cr']:'') .'</td>
<td align="right">'. (($val['Dr']!=0)?$val['Dr']:'').'</td>
</tr>
';
}
//displaying other accounts
foreach($acc as $key=>$val){
$bg = ($bg=='#eeeeee') ? '#ffffff' : '#eeeeee';
echo '<tr bgcolor="'. $bg .'">
<td align="left">'. $key .'</td>
<td align="left">'. (($val['trans']=='Dr')?$val['amount']:'') .'</td>
<td align="right">'. (($val['trans']=='Cr')?$val['amount']:'') .'</td>
</tr>
';
}
echo '</table>';
ACCOUNT DEBIT CREDIT
bank 5000
cash 2000 500
TUITION 7000
Repairs 500
|
SQL Query for Aged Trial Balance Report in MySQL
Date : March 29 2020, 07:55 AM
I hope this helps you . So far my query produces customers' accounts' current balance and the total amounts that were invoiced during the following groups of days after the report is generated: 0-30, 30-60, 60-90, 90+. SELECT account_number,
Balance,
`0-30` - (total_invoices - Balance - LEAST(`90+` + `60-90` + `30-60`, total_invoices - Balance)) AS `0-30`,
`30-60` - (total_invoices - Balance - LEAST(`90+` + `60-90`, total_invoices - Balance)) AS `30-60`,
`60-90` - (total_invoices - Balance - LEAST(`90+`, total_invoices - Balance)) AS `60-90`,
GREATEST(0, `90+` - (total_invoices - Balance)) AS `90+`
FROM (...)
|
Google cloud free trial billing account closed after 1 week with balance remaining
Date : March 29 2020, 07:55 AM
help you fix your problem The free trial account was suspended. Reason - "Unfortunately, we were unable to verify billing instrument ownership using the documents you submitted" says Google. Solution
|