subject
Engineering, 14.02.2020 16:32 lovecats12

Write a script that declares and sets a variable that’s equal to the total outstanding balance due. If that balance due is greater than $10,000.00, the script should return a result set consisting of VendorName, InvoiceNumber, InvoiceDueDate, and Balance for each invoice with a balance due, sorted with the oldest due date first. If the total outstanding balance due is less than or equal to $10,000.00, return the message "Balance due is less than $10,000.01"

Which query(ies) are viable solutions for the problem statement above?

DECLARE @TotalDue money;Set @TotalDue = (Select sum(InvoiceTotal-PaymentTotal-Credi tTotal)
From Invoices);
if @TotalDue > 10000 (select Vendors. VendorName, Invoices. InvoiceNumber, Invoices. InvoiceDueDate, (InvoiceTotal-PaymentTotal)
AS Balance from Invoices INNER JOIN Vendors on Invoices. VendorID=Vendors. VendorID --ORDER by InvoiceDueDate ASC)
Else Print 'Invoices pard in full'

DECLARE @OutstandingBalance money
DECLARE @VendorID int
SET @VendorID = @@VendorID --Error: Must declare the scalar variable "@@VendorID".
SET @OutstandingBalance = (
SELECT SUM(InvoiceTotal-(PaymentTotal+Cred itTotal))
FROM Invoices
WHERE Invoices. VendorID = @VendorID AND (InvoiceTotal-(PaymentTotal+CreditT otal)) > 10000
)--end the Select stmt
IF @OutstandingBalance > 10000
BEGIN
SELECT VendorName, InvoiceNumber, InvoiceDueDate, (InvoiceTotal-(PaymentTotal+CreditT otal)) as Balance
FROM Invoices JOIN Vendors On Vendors. VendorID = Invoices. VendorID
WHERE Invoices. VendorID = @VendorID
ORDER BY InvoiceDate ASC
END
ELSE
BEGIN
PRINT 'Balance due is small enough.'
END

Declare @totalInvoiceDue money;
select @totalinvoicedue = Sum(Invoicetotal - creditTotal - paymenttotal) from invoices where invoivetotal - credittotal - paymenttotal > 0;
if @totalInvoiceDue > 10000
select vendorName, InvoiveNumber, InvoiveDueDate, InvoiveTotal - credittotal - paymenttotal AS Balance
from invoives join vendors -- cross join
on invoices. vendorID = vendors. vendorID
where invoicetotal - credittotal - paymenttotal > - order by invoiceDueDate;
else
print 'Balance due is small enough';

USE AP;
DECLARE @TotalDue money;
SET @TotalDue = (SELECT SUM(InvoiceTotal - PaymentTotal - CreditTotal)
From Invoices);
If @TotalDue <10000
PRINT 'Balance due is small enough';
else
PRINT 'Name' + CONVERT(varchar,@VendorName,1)
'Invoice number' +CONVERT(int,@InvoiceNumber,1)
'Due date' +CONVERT(int,@InvoiceDueDate,1)
'Balace' + CONVERT(varchar,@TotalDue,1)
ORDER BY oldest_date from InvoiceDueDate

DECLARE @TotalDue money;
SELECT @TotalDue = SUM(InvoiceTotal - CreditTotal - PaymentTotal)
FROM Invoices
Where InvoiceTotal - CreditTotal - PaymentTotal > 0;
IF @TotalInvoiceDue > 10000
SELECT VendorName, InvoiceNumber, InvoiceDueDate, InvoiceTotal - CreditTotal - PaymentTotal AS Balance
FROM Invoices JOIN Vendors
ON Invoices. VendorID = Vendors. VendorID
WHERE InvoiceTotal - CreditTotal - PaymentTotal > 0
ORDER BY InvoiceDueDate
ELSE
PRINT 'Balance due is less than $10,000.01.';

Use AP
DECLARE @TotalInvoiceDue money;
SELECT @TotalInvoiceDue =
SUM(InvoiceTotal - CreditTotal - PaymentTotal)
FROM Invoices
--
print @TotalInvoiceDue
--
IF @TotalInvoiceDue > 10000
SELECT VendorName, InvoiceNumber, InvoiceDueDate,
InvoiceTotal - CreditTotal - PaymentTotal AS Balance
FROM Invoices JOIN Vendors
ON Invoices. VendorID = Vendors. VendorID
WHERE InvoiceTotal - CreditTotal - PaymentTotal > 0
ORDER BY InvoiceDueDate;
ELSE
PRINT 'Balance due is less than $10,000.01.';

DECLARE @Balance money
SET @Balance = (SELECT SUM(Invoices. InvoiceTotal - (Invoices. PaymentTotal - Invoices. CreditTotal)) FROM Invoices)
IF @Balance > 10000
BEGIN
SELECT VendorName AS 'Vendor Name', InvoiceDueDate AS 'Due Date', InvoiceNumber AS 'Invoice#', Invoices. InvoiceTotal - (Invoices. PaymentTotal - Invoices. CreditTotal) AS 'Balance' FROM Invoices
INNER JOIN Vendors ON Vendors. VendorID=Invoices. VendorID
WHERE (InvoiceTotal - (Invoices. PaymentTotal - Invoices. CreditTotal)) <> 0
ORDER BY InvoiceDueDate ASC
END
ELSE
PRINT 'Balance due is small enough.'

DECLARE @OutstandingBalance money
Set @OutstandingBalance = (
SELECT Top 1 (InvoiceTotal-(PaymentTotal+CreditT otal))
FROM Invoices
Order By (InvoiceTotal-(PaymentTotal+CreditT otal)) desc
);
--
print @OutstandingBalance;
--
SELECT VendorName, InvoiceNumber, InvoiceDueDate, @OutstandingBalance as Balance
FROM Invoices JOIN Vendors On Vendors. VendorID = Invoices. VendorID
ORDER BY InvoiceDate

ansver
Answers: 2

Another question on Engineering

question
Engineering, 03.07.2019 14:10
The y form of iron is known as: a) ferrite b) cementite c) perlite d) austenite
Answers: 3
question
Engineering, 04.07.2019 18:10
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
If a particle moves along a path such that r : (3 sin t) m and ? : 2t rad, where t is in seconds. what is the particle's acceleration in m/s in 4 seconds? a)- 16.43 b)- 16.29 c)- 15.21 d)- 13.79
Answers: 1
question
Engineering, 04.07.2019 18:10
Ajournal bearing has a journal diameter of 3.250 in with a unilateral tolerance of 20.003 in. the bushing bore has a diameter of 3.256 in and a unilateral tolerance of 0.004 in. the bushing is 2.8 in long and supports a 700-lbf load. the journal speed is 900 rev/min. find the minimum oil film thickness and the maximum film pressure for both sae 20 and sae 20w-30 lubricants, for the tightest assembly if the operating film temperature is 160°f. a computer code is appropriate for solving this problem.
Answers: 3
You know the right answer?
Write a script that declares and sets a variable that’s equal to the total outstanding balance due....
Questions
question
Mathematics, 10.12.2020 06:20
Questions on the website: 13722362