将库中的数据用SQL处理后,得出的结果,不能直接用DBGrid一类的控件显示,如:SELECT Category =
CASE type
WHEN 'popular_comp' THEN 'Popular Computing'
WHEN 'mod_cook' THEN 'Modern Cooking'
WHEN 'business' THEN 'Business'
WHEN 'psychology' THEN 'Psychology'
WHEN 'trad_cook' THEN 'Traditional Cooking'
ELSE 'Not yet categorized'
END,
CAST(title AS varchar(25)) AS 'Shortened Title',
price AS Price
FROM titles
WHERE price IS NOT NULL
ORDER BY type, price
COMPUTE AVG(price) BY type结果如下(取自SQL Server2000帮助)Category Shortened Title Price
------------------- ------------------------- --------------------------
Business You Can Combat Computer S 2.99
Business Cooking with Computers: S 11.95
Business The Busy Executive's Data 19.99
Business Straight Talk About Compu 19.99 avg
==========================
13.73 Category Shortened Title Price
------------------- ------------------------- --------------------------
Modern Cooking The Gourmet Microwave 2.99
Modern Cooking Silicon Valley Gastronomi 19.99 avg
==========================
11.49 Category Shortened Title Price
------------------- ------------------------- --------------------------
Popular Computing Secrets of Silicon Valley 20.00
Popular Computing But Is It User Friendly? 22.95 avg
==========================
21.48 Category Shortened Title Price
------------------- ------------------------- --------------------------
Psychology Life Without Fear 7.00
Psychology Emotional Security: A New 7.99
Psychology Is Anger the Enemy? 10.95
Psychology Prolonged Data Deprivatio 19.99
Psychology Computer Phobic AND Non-P 21.59 avg
==========================
13.50 Category Shortened Title Price
------------------- ------------------------- --------------------------
Traditional Cooking Fifty Years in Buckingham 11.95
Traditional Cooking Sushi, Anyone? 14.99
Traditional Cooking Onions, Leeks, and Garlic 20.95 avg
==========================
15.96 这样的数据,如何显示出来,DBGrid只能显示出一个表
CASE type
WHEN 'popular_comp' THEN 'Popular Computing'
WHEN 'mod_cook' THEN 'Modern Cooking'
WHEN 'business' THEN 'Business'
WHEN 'psychology' THEN 'Psychology'
WHEN 'trad_cook' THEN 'Traditional Cooking'
ELSE 'Not yet categorized'
END,
CAST(title AS varchar(25)) AS 'Shortened Title',
price AS Price
FROM titles
WHERE price IS NOT NULL
ORDER BY type, price
COMPUTE AVG(price) BY type结果如下(取自SQL Server2000帮助)Category Shortened Title Price
------------------- ------------------------- --------------------------
Business You Can Combat Computer S 2.99
Business Cooking with Computers: S 11.95
Business The Busy Executive's Data 19.99
Business Straight Talk About Compu 19.99 avg
==========================
13.73 Category Shortened Title Price
------------------- ------------------------- --------------------------
Modern Cooking The Gourmet Microwave 2.99
Modern Cooking Silicon Valley Gastronomi 19.99 avg
==========================
11.49 Category Shortened Title Price
------------------- ------------------------- --------------------------
Popular Computing Secrets of Silicon Valley 20.00
Popular Computing But Is It User Friendly? 22.95 avg
==========================
21.48 Category Shortened Title Price
------------------- ------------------------- --------------------------
Psychology Life Without Fear 7.00
Psychology Emotional Security: A New 7.99
Psychology Is Anger the Enemy? 10.95
Psychology Prolonged Data Deprivatio 19.99
Psychology Computer Phobic AND Non-P 21.59 avg
==========================
13.50 Category Shortened Title Price
------------------- ------------------------- --------------------------
Traditional Cooking Fifty Years in Buckingham 11.95
Traditional Cooking Sushi, Anyone? 14.99
Traditional Cooking Onions, Leeks, and Garlic 20.95 avg
==========================
15.96 这样的数据,如何显示出来,DBGrid只能显示出一个表
解决方案 »
- 再问多线程保存数据表数据问题,在线急等,高手进
- 图片数字控件,DELPHI中有没有这个控件呀
- (求救)DELPHI 一按RUN运行时就跳出CPU窗口
- 如果把别的应用程序的qrp文件转为excel或html
- 散分,十位一结,11以后没分。需要分的同志来哪,10分左右一贴,不犯法吧?2
- 怎样用winsock api发送smtp验证邮件?
- 一次遍历一个form上的相同类型的控件是怎么写的?比如说checkbox
- 我在用ActiveX的TShockwaveFlash的时候,当改变窗体大小的时候,TShockwaveFlash却不能………
- 求解数据库连接问题,在线等待。急!!!
- 用COM+,出现一般性拒绝访问错误?
- 紧急问题,在线等……
- 添加组件时出现的问题
要显示这样的格式,据我的经验DBGrid是做不到的。
报表还可以考虑一下。
至于用什么报表,自己选吧。