Create a table for invoices that have been paid. Name this table invoicespaid. T
ID: 3853877 • Letter: C
Question
Create a table for invoices that have been paid. Name this table invoicespaid. The table should have columns for the VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal, AccountNo, InvoiceLineItemAmount, and InvoiceLineItemDescription. You can use this create table statement. CREATE TABLE [dbo].[invoicespaid]( [VendorName] [varchar](200) NOT NULL, [InvoiceNumber] [varchar](50) NOT NULL, [InvoiceDate] [smalldatetime] NOT NULL, [InvoiceTotal] [money] NOT NULL, [AccountNo] [int] NOT NULL, [InvoiceLineItemAmount] [money] NOT NULL, [InvoiceLineItemDescription] [varchar](300) NOT NULL)
Insert into the invoicespaid table all of the records from the invoices and invoicelineitems tables that have been paid. Make sure this is an insert into statement that is using a select statement to get the records from the invoices and invoicelineitems tables.
Now, you want to mark those records that have been moved to this table. Add a column named moved to the invoices table using an alter table statement.
Write an update statement to update the records that were moved to true. All other records should be false.
1 create table statement, 1 insert statement, 1 alter table statement, 1 update statement
(Make sure your insert statement uses a select statement to pull values from the invoices and invoicelineitems table)
Need help please.
Thank you
Explanation / Answer
CREATE TABLE[dbo].[invoicepaid](
[VendorName][varchar](200)NOT NULL,
[InvoiceNumber][varchar](50) NOT NULL,
[InvoiceDate][smalldatetime] NOT NULL,
[InvoiceTotal][money] NOT NULL,
[AccountNo][int] NOT NULL,
[InvoiceLineItemAmount][money] NOT NULL,
[InvoiceLineItemDescription][varchar](300) NOT NULL);
INSERT INTO invoicepaid
(
VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal,
AccountNo, InvoiceLineItemAmount, InvoiceLineItemDescription
)
VALUES (Select e.vendorname, e.InvoiceNumber, e.InvoiceDate, e.InvoiceTotal, e.AccountNo, t.InvoiceLineItemAmount,
t.InvoiceLineItemDescription
FROM Invoice as e, InvoiceLineItemDescription as t
WHERE e.invoice_paid = ‘paid’
);
ALTER TABLE invoice ADD moved BIT NOT NULL DEFAULT 0;
UPDATE TABLE invoice SET moved = 1
WHERE invoice_paid = ‘paid’;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.