Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ORACLE SQL Problem 2 Given the following tables and data: create table months (monthIndex int); create table invoice(invoiceId int, month int) create table lineitems(lid int,

ORACLE SQL Problem 2

Given the following tables and data:

create table months (monthIndex int);

create table invoice(invoiceId int, month int)

create table lineitems(lid int, invoiceID int, charged_amount decimal(6,2), contracted_rate decimal(6,2))

Insert into months values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);

Insert into invoice values

(1,1), (2,1), (3,2) (4,2), (5,4), (6,5), (7,5), (8,8), (9,8), (10,3), (11,3), (12,6), (13,7), (14,10), (15,11), (16,11);

Insert into lineitems values

(1,1,1000.10,1000.10),

(2,1,1500.20,1200.00),

(3,1,1300.10,1300.10),

(4,2,2100.30,2100.30),

(5,2,1100.10,1000.10),

(6,2,1100.40,1100.40),

(7,3,6000.10,6000.40),

(8,3,1400.10,1400.40),

(9,4,4500.10,4500.10),

(10,5,3300.10,3000.18),

(11,5,2900.10,2900.10),

(12,6,8900.10,8900.10),

(13,6,2200.10,2200.10),

(14,8,3700.10,3700.50),

(15,9,7000.10,7000.60),

(16,10,2200.10,2200.10),

(17,10,2200.10,2200.10),

(18,11,2200.10,2200.10),

(19,12,2200.10,2200.10),

(20,13,2200.10,2200.10),

(21,13,2200.10,2200.10),

(22,14,1100.10,1000.10),

(23,14,1100.40,1100.40),

(24,14,6000.10,6000.40),

(25,15,1400.10,1400.40),

(26,16,4500.10,4500.10),

(27,16,3300.10,3000.18);

Develop a single SQL Query that computes the total invoices amount for each month , and the percentage of change from the previous month. If there are no invoices for the month , the computed value should be null.

Here is the result that the query should generate:

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

Students also viewed these Databases questions