I need to write a query in Microsoft Access to summarize this data:
Date
Description
Amount
02/15/20
Initial Fund Balance
10000
06/21/20
Fund Contribution
2000
12/01/20
Fund Appreciation
5250
12/01/21
Fund Appreciation
5418
12/01/22
Fund Appreciation
5610
03/16/23
Fund Contribution
3500
12/01/23
Fund Appreciation
5814
Select year(Date) as MyDate, Sum(Amount) as FundBal
from Tran
Group by Year(Date)
This summarizes the activity for each year but does not include the activity from prior years.
I need a MS Access Query to Total the fund balance by year and return the following:
Year
Balance
2020
17250
2021
22668
2022
28278
2023
37592
Thanks in advance for any help.
Keith
Related
I have table of EMPLOYEE , in which I need to show the salary from this month to this month .
Suppose I have dates eg. from date 17/01/2020 and to date 18/02/2020 I need monthly data between these two dates like from 17th JAN to 30th JAN one data and from 1st FEB to 28th FEB.
Please suggest some query i trying it but not able to fetch between two dates.
select add_months (to_date(from_date,'dd/mm/yyyy' ), - (level-1)), 'Mon yy') as MONTH,SALARAY from EMPLOYE_BG where CREATED_DATE between TO_DATE('17/01/2020','dd/mm/yyyy')
and to_date('10/03/2020','dd/mm/yyyy')
O/P:
MONTH SALARY
----------------
JAN-20 30000
FEB-20 50000
MAR-20 60000
like this i am expecting the result
SELECT * FROM EMPLOYE_BG
SALARY EMPNAME CREATED_DATE
---------------------------------
30000 JACK 07/01/2020
30000 SWETA 08/01/2020
30000 RAM 08/01/2020
40000 JOHN 01/02/2020
60000 SIMON 10/03/2020
70000 KIRA 11/04/2020
this is table details
I've got a large database that's got all our transactions and shipping costs from them, here's a simplified version:
Source Table
Date
ROUTE
Cost
01/20/21
USA to UK
$40
01/01/21
USA to UK
$40
01/10/21
USA to UK
$40
12/20/20
USA to UK
$30
11/20/20
USA to UK
$20
11/20/20
USA to UK
$20
And I want to see the average cost by month before so it would look like:
Route
Nov 2020
Dec 2020
Jan 2020
USA to UK
$20
$30
$40
How do I write a code that I can repeat for when say April comes around and I have to refresh this table and I don't need to create new columns for Feb, March, etc.?
Here is a possible way of doing it by using PIVOT in Snowflake: https://docs.snowflake.com/en/sql-reference/constructs/pivot.html
Let's say "monthname" is a column you extracted out of your "Date"-column, probably this helps:
select * from yourTable
pivot(sum(cost) for monthname in ('January', 'February', 'March', 'April'))
order by route;
The values of your monthname-column should match the one in the brackets.
As this is a more static solution, you still have to adjust the code every month. Here probably writing a stored procedure is helping: https://docs.snowflake.com/en/sql-reference/stored-procedures.html
I need to get number of vacant days in each month in every year
Leasing Contracts
So, my target is to occupy all units along the year.
For that I have to find how many days in each month units are not occupied (There s not contract) and focus on these units to reduce the price or give promotions.
So, I have lease start and lease expiry dates for the units in the first table and I want to know in summary table (second table) number of days in each month which are not belong to any of the leasing period (from/to range) from the first table for each unit.
I need Excel formulas and/or SQL scripts to be applied to find all days without rent for each project/unit in the selected year
Appreciate your support in advance!
Project Name Unit No Lease Start Lease Expiry Rent Per Annum
Building1 Unit1 01-01-2017 31-12-2017 70000
Building1 Unit1 01-01-2018 15-08-2018 60000
Building1 Unit1 01-10-2018 31-12-2018 60000
Building1 Unit2 01-01-2017 31-12-2017 60000
Building1 Unit2 01-03-2018 31-07-2018 60000
Building1 Unit2 01-09-2018 30-09-2018 45000
Vacancies Days multiply by last daily rate renting (rent per annum)/365
Project Name Unit No Jan-18 Feb-18 Aug-18 Sep-18 Oct-18
Building1 Unit1 0 0 16*164 30*164 0
Building1 Unit2 31*164 28*164 31*164 0 31*123
I would use a calendar table.
This you join with your lease table to get whether a particular day is leased or not.
Then you can group by unit and month and do a pivot to get the result you want.
We are working with a database that tracks payment plans for patients. Some patients pay monthly, some weekly, and some every other week.
The PaymentsSchedule table fields are Patient, Frequency, NextDueDate, PaymentsRemaining, Amount. Once a payment is processed the NextDueDate and PaymentsRemaining fields are updated so that at any given time there is only one record representing all future payments for a given payment plan.
The report we want to generate would show all payments expected within the next month. Something like this:
Report Date: 3/1/2014
Patient Frequency Next Date Pmts Left Amount
01 Monthly 3/01/2014 5 $100
02 Weekly 3/02/2014 3 $30
03 Weekly 3/02/2014 7 $25
04 Bi-Weekly 3/03/2014 4 $75
02 Weekly 3/09/2014 2 $30
03 Weekly 3/09/2014 6 $25
02 Weekly 3/16/2014 1 $30
03 Weekly 3/16/2014 5 $25
04 Bi-Weekly 3/17/2014 3 $75
03 Weekly 3/23/2014 4 $25
03 Weekly 3/30/2014 3 $25
I could set up 5 different queries for the 5 date possibilities (weekly) of a payment plan for the next 31 days, pull them together in a UNION and then filter out dates that are not in my time horizon but I would like to find a simpler solution.
Your help is much appreciated.
Thanks,
Jim S
I show my table structure below. I want the record like the second structure. Please help me to get this using oracle or SQL.
FLd_Date Fld_Via Fld_Amt
11/1/2013 cash 100.26
11/2/2013 online 123.00
11/3/2013 cash 32.00
11/4/2013 cash 234.00
11/5/2013 cash 125.00
11/6/2013 online 125.00
11/7/2013 cash 200.00
11/8/2013 online 111.00
11/9/2013 online 143.00
11/10/2013 cash 155.00
11/11/2013 online 12.00
11/12/2013 online 142.00
I want the output like this
mode count total
cash 6 846.26
online 6 656
select fld_via as mode,
count(*) as count,
sum(fld_amt) as total
from your_table
group by fld_via
Please try:
select
Fld_Via as "mode",
count(*) as "count",
sum(Fld_Amt) as "total"
from
YourTable
Group by Fld_Via