PostgreSQL: Write stored procedure/SQL statement

I need a stored procedure (in PLPgsql or SQL) or a pure SQL statement.

I have the table seen below and I need someone to go through all the entries in the table and on duplicates set the "deleted" column to "true" and add the following text to the beginning of the "text" column: duplicate of receipt with id: X. Please only mark the receipt with the highest id as duplicate and do not change anything on the duplicate with the lowest id.

Please provide one single sql statement, which will create the tables, drop the old stored procedure, create the new stored procedure, add sample data to the table and show output from your stored procedure. Your sample data should cover all special cases so I will not need to make any additional tests.


CREATE TABLE receipts (


customer_id INT,

receipt_number SERIAL,

entry_date DATE,

text VARCHAR(9999),

amount NUMERIC(20, 2) DEFAULT 0.00,

amount_original_currency NUMERIC(20, 2) DEFAULT 0.00,

currency currency_enum DEFAULT 'DKK', -- Use USD for dollar, DKK for danish kroner etc.

vat_code VARCHAR(10), -- Used to record the VAT code of the company our customer has bought from or sold to.

deleted BOOLEAN DEFAULT false


Receipts are duplicate if the following are equal:

- Entry_date

- either amount or amount_original_currency

- vat_code (or if one or both of these are blank or null)

I will pay 15$ for this, and you must deliver within 2 days. Please provide your [url removed, login to view] username in your bid.

Evner: Database Administration, SQL

Se mere: do anything for a dollar, postgresql any, stored, sql duplicates, Sql Database administration, postgresql c++, database receipts, sql statement stored, code create database record, postgresql text date, receipt sample code, add tables sql, postgresql serial, code stored database, postgresql procedure, stored procedure create sql, postgresql sql, database procedure, write use cases, create stored procedure postgresql, sample code receipt, postgresql table, write text data sql, company statement, sql int date

Om arbejdsgiveren:
( 165 bedømmelser ) Copenhagen, Denmark

Projekt ID: #4088612

Tildelt til:


Hello, Let me do this task for you too. Thanks.

$15 USD / time
(6 bedømmelser)