PostgreSQL: Create SQL statement/stored procedure

In Progress Posted Jan 2, 2013 Paid on delivery
In Progress

I need a stored procedure (in PLPgsql or SQL) or a pure SQL statement. The database schema is:

DROP TABLE IF EXISTS receipts;

CREATE TABLE receipts (

id SERIAL PRIMARY KEY,

entry_date DATE,

amount NUMERIC(20, 2) DEFAULT 0.00

);

DROP TABLE IF EXISTS bank_transactions;

CREATE TABLE bank_transactions (

id serial NOT NULL,

transaction_date DATE,

amount NUMERIC(20, 2)

);

The point of your procedure is to match any group of bank_transactions to any group of receipts or the other way around, so that the sum of the amount in a group equals the sum of the amount in the other group. For example the following two rows in receipts table will match a row in transactions with the amount 20.00:

10.00

10.00

One or more rows in receipts may match the sum of one or more rows in transactions, and the other way around. The output of your query or stored procedure should be in the following format:

array of ints of matching receipt ids array of ints of matching transaction ids

[1, 3, 8] [2,3,8]

The example data above means that the sum of receipts with ids 1, 3 and 8 match the sum of the transactions with ids 2, 3 and 8. Please use the array data type for this.

The price for this project is 20$ and the deadline is 2 days.

Please provide your [url removed, login to view] username in your bid.

Database Administration SQL

Project ID: #4088429

About the project

1 proposal Remote project Active Jan 2, 2013

Awarded to:

truongngocthanh

Hello, I can done this task quickly. Please check your PM. Thank you.

$8 USD / hour
(6 Reviews)
3.1