当前位置:数据库 > Oracle >>

ORACLE数据库查询语句

List the product description and year the product was placed in inventory, for all products placed in inventory after 2010. 列出产品说明和产品进入库存的年份(2010年之后) List the average line units sold on any invoice line 列出所有发票中销售出的商品的平均量 How many different products are on each invoice? Show the result in descending order by the number of products 每张发票有多少商品?以降序排列商品的数量 List the product names and number of months in inventory for those products with “in dates” greater than 12 months. Sort by time in inventory (descending). (Tip: Use Sysdate) 列出商品名称和进入库存的时间(超过12个月)。按时间降序排列。 How many customers have address in each city? Sort in a descending order 每个城市中有多少顾客有地址?降序排列 For each invoice, display the total invoice cost. Sort by invoice total in a descending order.excluding those rows with invoice totals less than 499.99. 显示每张发票的总价值,按总额降序排列。不包括价格低于499.99的产品 我可以提供sql文件 期望前辈能加我详谈
补充:更正一下,
每张发票有多少商品?以降序排列商品的数量应该是
每张发票有多少不同商品,降序排列商品数。不好意思。。
另外补充一个。。
List the customer last name, invoice number, invoice date and product description for all December invoices?.
列出所有12月份的顾客的姓,发票号,发票日期和产品说明

谢谢大伙了!
追问:我想问查询语句,谢谢谢谢解答,我补充了一下,能在帮我看一下嘛。。
你可以加我zzzyk我就想问问查询语句,如果能加我zzzyk,我可以吧sql给你
谢谢
答案:PL/SQL代码,所有代码都经过了测试:

--列出产品说明和产品进入库存的年份(2010年之后)
SELECT  Prod_Description, Prod_Indate
FROM    PRODUCT
WHERE   TO_DATE(Prod_Indate,'yyyy-MM-dd') > TO_DATE('2010-1-1','yyyy-MM-dd');

--列出所有发票中销售出的商品的平均量
SELECT  AVG(Line_units) AS avg_unit
FROM    Invoice_Line;

--每张发票有多少商品?以降序排列商品的数量
SELECT  Invoice_Number, SUM(Line_units) AS sum_units
FROM Invoice_Line
GROUP BY Invoice_Number
ORDER BY sum_units DESC;

--列出商品名称和进入库存的时间(超过12个月)。按时间降序排列。
SELECT  Prod_Description, Prod_Indate
FROM    PRODUCT
WHERE   CEIL(MONTHS_BETWEEN(sysdate, TO_DATE(Prod_Indate, 'yyyy-mm-dd hh24:mi:ss'))) > 12;

--每个城市中有多少顾客有地址?降序排列
SELECT  Cust_City, COUNT(*) AS num
FROM    Customer
GROUP BY Cust_City
ORDER BY num DESC;

--显示每张发票的总价值,按总额降序排列。不包括价格低于499.99的产品
SELECT  Invoice_Number, SUM(Line_units * Line_Price) AS TotalValue
FROM    Invoice_Line
WHERE   Line_Price < 499.99
GROUP BY Invoice_Number
ORDER BY TotalValue DESC;
其他:嗯,你这介要问什么呢? 1、SELECT 产品说明,入库年份FROM 表 WHERE 年份>2010;
你没有给表的名称,也没有给表的结构所以我只能是用语言描述,你把我写的语句的文字换成你的表格相应的字段名就可以了。
2、列出所有发票中销售出的商品的平均量
select AVG(销售量)from 表名;
3、每张发票有多少商品?以降序排列商品的数量
select sum(商品)from 表名 group by 发票号 order by desc;
4、每个城市中有多少顾客有地址?降序排列
select sum(顾客)from 表名 where 地址 is not null ;
5、显示每张发票的总价值,按总额降序排列。不包括价格低于499.99的产品
select sum(发票价值)as 总价值 from 表名 where 价格>=499.99 order by desc;
仅供参考 你想问什么呢。看你的需求,实现这些要求应该不难呀 

上一个:oracle 10g连接My Eclipse 8.5,jdk1.6.0_10,老是报错,求解,数据库大神进啊!!!
下一个:求oracle数据库的一个建表方案

Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,