In Progress

PostgreSQL: Write SQL statement

I have lots of data in a table with the following structure:

CREATE TABLE receipts

(

id serial NOT NULL,

customer_id integer,

receipt_number serial NOT NULL,

image_name character varying(255),

entry_date date DEFAULT ('now'::text)::date,

text character varying(9999),

amount numeric(20,2) DEFAULT 0.00,

account integer,

vat_code character varying(10),

offset_account integer,

s3_path_to_original_file character varying(300),

received_date timestamp without time zone,

deleted boolean DEFAULT false,

typed integer DEFAULT 0,

checked boolean DEFAULT false,

reconciled boolean DEFAULT false,

accounted boolean DEFAULT false,

s3_path_to_image character varying(300),

CONSTRAINT receipts_pkey PRIMARY KEY (id)

)

I need to keep the data as it is, while converting to the following schema.

CREATE TABLE receipts (

id SERIAL PRIMARY KEY,

customer_id INT,

receipt_number SERIAL,

image_name CHARACTER VARYING(255),

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.

account INT,

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

offset_account INT,

s3_path_to_original_file VARCHAR(300),

s3_path_to_image VARCHAR(300),

received_date TIMESTAMP,

deleted BOOLEAN DEFAULT false,

typed SMALLINT DEFAULT 0, -- Number of typers that have typed the amount

checked BOOLEAN DEFAULT false,

reconciled BOOLEAN DEFAULT false,

receipt_type SMALLINT DEFAULT 0, -- Receipt 0 is unknown, 1 means entry_date is before bank transaction (invoice/bill/cash payment), 2 is after, 3 is immediately after or same date

expense BOOLEAN DEFAULT true, -- If it is not an expense, it is an income

accounted BOOLEAN DEFAULT false,

degrees SMALLINT DEFAULT 0, -- Used for storing the number of degrees to rotate the image.

email_conversation VARCHAR(9999) DEFAULT '' -- Used for store the email conversation when the user ask to customer.

);

The first one to deliver working SQL statements (probably involving ALTER TABLE) to achieve this gets 15$.

Skills: SQL

See more: postgresql text date, key bank, dollar bank, with bank statements, vat payment, postgresql c++, income statement, statement structure sql, image typers, write conversation, bill invoice, schema sql, receipt invoice, receipt image, image serial, postgresql serial, postgresql sql, danish store, statements character, postgresql table, write text data sql, company statement, sql int date, converting sql, write usd

About the Employer:
( 165 reviews ) Copenhagen, Denmark

Project ID: #4138110

Awarded to:

lokeshk9936

Please see PM.

$10 USD / hour
(3 Reviews)
2.8

12 freelancers are bidding on average $14/hour for this job

weonlydo

Hi, if you're serious about getting this done, please accept my bid and let's start.

$20 USD / hour
(12 Reviews)
4.5
kultech

I can done. Please contact with me. I will show demo for you. Thank You

$15 USD / hour
(4 Reviews)
4.3
manhpham

I am ready to help you. please contact me asap.

$15 USD / hour
(9 Reviews)
4.2
silvioq

Hi. I'm Silvio from Argentina. Check my PM

$15 USD / hour
(2 Reviews)
3.8
osinee

Hi, create milestone for me and I'll delivery script for you right now.

$15 USD / hour
(3 Reviews)
3.1
truongngocthanh

Hello, Let me do this for you. Will done quickly. Thanks

$15 USD / hour
(6 Reviews)
3.1
sathish2connect

Hi, I can do this. Ready to start asap. Thanks

$10 USD / hour
(6 Reviews)
2.3
mlambrichs

Read my PM.

$15 USD / hour
(3 Reviews)
2.1
javaguru75

Let me do it.

$15 USD / hour
(0 Reviews)
0.0
jalves

I specialize in SQL Server but also know PostgreSQL. I believe that the task is simple and the goal can be easily achieved.

$15 USD / hour
(0 Reviews)
0.0
vivekbgiri

sir, I am Oracle Certified developer i can do your job within time. Thank you.

$8 USD / hour
(0 Reviews)
0.0
Caronettech

Hi Sir, I am ready to work on this Please provide me, Thanks

$10 USD / hour
(0 Reviews)
0.0