你是一个食物批发商的数据库开发者.每星期,公司完成不同顾客的订单.通常,每个顾客每星
SELECT i1.InvoiceNumber, i1.CustomerName, i1.InvoiceAmountFROM Invoice As i1, Invoice AS i2GROUP BY i1.InvoiceNumber, i1.CustomerName, i1.InvoiceAmountHAVING i1.InvoiceAmount < AVG (i2.InvoiceAmount)ORDER BY i1.CustomerName, i1.InvoiceNumber
SELECT i1.InvoiceNumber, i1.CustomerName, i1.InvoiceAmountFROM Invoice As i1WHERE i1.InvoiceAmount <(SELECT AVG (i2.InvoiceAmount)FROM Invoice AS i2WHERE i2.CustomerName=i1.CustomerName)ORDER BY i1.CustomerName, i1.InvoiceNumber
SELECT i1.InvoiceNumber, i1.CustomerName, i1.InvoiceAmountFROM Invoice As i1WHERE i1.InvoiceAmount <(SELECT AVG (i2.InvoiceAmount)FROM Invoice AS i2)ORDER BY i1.CustomerName, i1.InvoiceNumber
SELECT i1.InvoiceNumber, i1.CustomerName, i1.InvoiceAmount,CASE WHEN i1.InvoiceAmount < AVG (i2.InvoiceAmount)THEN i1.InvoiceAmount ELSE 0 END FROM Invoice As i1 INNER JOIN Invoice AS i2ON i1.CustomerName = i2.CustomerNameGROUP BY i1.InvoiceNumber, i1.CustomerName, i1.InvoiceAmountORDER BY i1.CustomerName, i1.InvoiceNumber
参考答案: