编写检索的SQL,以检索提交维修的每个设备的序列号,描述,销售日期,请求维修的客户名称,维修说明以及维修费用。(需要加入两个表)。
格式化输出,使其以句子形式输出,如下所示:
“为解决DVD Stuck问题,在2018年1月1日出售给A.GREEN的9001 DVD DVD播放机维修费用为67.50欧元”。
如果不存在十进制值,请确保输出零。
不知道该用什么来格式化输出..搜索dbms并打印,但我不确定这是否是问题的根源。提前致谢!
客户表
CUSTID | CUSTNAME | CUSTPHONE | CUSTEMAIL
1001 Aaa 0123 [email protected]
1002 BBB 0121 [email protected]
1003 CCCC 0333 [email protected]
appRepair表
serialNO | RepairDate| RepairDesc| repairCost | Customer_ID
9001 4-Mar-18 0123 67.5 1001
9002 4-JUN-18 0121 60.7 1002
9003 4-AUG-18 0333 102.5 1003
家电桌
serialNO | appDESC | APPSALEDATE | GUARENTEELENGTH
9001 DVD PLAYER 1-jan-18 2
9002 FRIDGE FREEZER 3-may-18 5
9003 48 TV 5-jun-18 2
我的选择查询代码
select appliance.serialNo, appliance.appDesc, TO_CHAR(appliance.appSaleDate, 'DDTH MONTH YY') AS "SALE DATE",
UPPER(Customer.custName) AS "CUSTOMER NAME", Customer.custEmail from appliance
inner join appRepair ON appliance.serialNo=appRepair.serialNo
inner join Customer ON appRepair.customer_id=Customer.custID;
预期产量:
“为解决DVD Stuck问题,在2018年1月1日出售给A.GREEN的9001 DVD DVD播放机维修费用为67.50欧元”。
您需要的是这样的:
select 'The repair to appliance '
|| appliance.serialNo
|| ' ' || appliance.appDesc
|| ', sold on '
|| LTRIM(to_char(appliance.appSaleDate,'ddth Month YYYY','NLS_DATE_language=American'), 0)
|| ' to ' || UPPER(Customer.custName)
|| ', to solve the issue'
|| appRepair.RepairDesc || ' will cost '
|| ltrim(to_char(appRepair.repairCost, 'L9990.99'))
from appliance
inner join appRepair ON appliance.serialNo = appRepair.serialNo
inner join Customer ON appRepair.customer_id = Customer.custID;
这将解决日期格式:
select LTRIM(to_char(sysdate,'ddth Month YYYY','NLS_DATE_language=American'), 0)
from dual;
这应该解决数字格式:
select to_char(00.00, 'L990.99')
from dual;
我没有您的桌子,但是如果出现任何错误,请告诉我,我将尽力提供帮助。这是为此的演示,因此您可以查看日期和数字格式的工作方式。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句