Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a PostgreSQL query for the following: You are given a history of your bank account transactions for the year 2020. Each transaction was either

Write a PostgreSQL query for the following:

image text in transcribed

image text in transcribed

You are given a history of your bank account transactions for the year 2020. Each transaction was either a credit card payment or an incoming transfer. cost of at least 100 within that month. Note that this fee is not included in the supplied history of transactions. At the beginning of the year, the balance of your account was 0 . Your task is to compute the balance at the end of the year. You are given a table transactions with the following structure: create table transactions ( amount integer not null, date date not null is an incoming transfer. There are no transactions with an amount of 0 . Examples: 1. Given table: your query should return: The balance without the credit card fee would be 2801 . You are charged a fee for every month except March, which in total equates to 11 * 5=55. are charged. The final balance is 280155=2746. 2. Given table: your query should return: you had three card payments for a total cost of 100+100+100=300. The final balance is 562105=612. 3. Given table: Your query should return: You earned 21000 but you are charged a fee for every month. The final balance is 2100012 * 5=20940. Assume that: - column date contains only dates between 2020-01-01 and 2020-12-31; - column amount contains only non-zero values

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions

Question

What were your most important educational experiences?

Answered: 1 week ago

Question

Which personal relationships influenced you the most?

Answered: 1 week ago