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

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 15:10, breannaasmith1122
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
image
Engineering, 03.07.2019 19:30, 10040813
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
image
Engineering, 04.07.2019 18:10, tjeffers90028
Refrigerant 134a enters an insulated compressor operating at steady state as saturated vapor at -26°c with a volumetric flow rate of 0.18 m3/s. refrigerant exits at 9 bar, 70°c. changes in kinetic and potential energy from inlet to exit can be ignored. determine the volumetric flow rate at the exit, in m3/s, and the compressor power, in kw.
Answers: 1
image
Engineering, 04.07.2019 18:10, johnthienann58
Thermal stresses are developed in a metal when its a) initial temperature is changed b) final temperature is changed c) density is changed d) thermal deformation is prevented e) expansion is prevented f) contraction is prevented
Answers: 2
You know the right answer?
Write a script that declares and sets a variable that’s equal to the total outstanding balance due....

Questions in other subjects:

Konu
History, 17.12.2020 18:50