由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Need help, about select count(xyz) from ...
相关主题
Re: Recordset - I stuck! Help!Re: 求教: Join 两个query (data) tables 出错
问一个简单的Query[转载] strong SQL skills?
Help on Oracle Query急问 hibernate query
query questions有什么优化query的常用方法
sql questiontbl1.col1 = tbl2.col2 (+)
[转载] Can anyone interpret this simple SQL?how to write this query
如何完成这个sql?query running long time
question on nested query请问个join的问题
相关话题的讨论汇总
话题: ford话题: brand话题: query话题: need话题: chevy
进入Database版参与讨论
1 (共1页)
n********6
发帖数: 1511
1
Background:
Garage manager wants a summary report for the times of service delivered to the customer per vehicle brand, by
this week, and this year as of today.
Table:
transactionid, Brand, date, ...
1, Ford, 5/1, ...
2, Ford, 5/2, ...
3, Chevy, 7/1, ...
...
m, n, o, 7/20, ...
Expected Output/report format:
Brand, CounterThisWeek(as of today), CouterThisYear(as of today)
Ford, 3, 118
Chevy, 1, 117
...
Toyota, 5, 125
Environment: SQLServer2005
Question:
Can this done by one query?
g***l
发帖数: 18555
2
明明是要GROUP BY两次么,为啥用一个QUERY,做样子?
i****a
发帖数: 36252
3
try group by brand
and in the query do case date count

to the customer per vehicle brand, by

【在 n********6 的大作中提到】
: Background:
: Garage manager wants a summary report for the times of service delivered to the customer per vehicle brand, by
: this week, and this year as of today.
: Table:
: transactionid, Brand, date, ...
: 1, Ford, 5/1, ...
: 2, Ford, 5/2, ...
: 3, Chevy, 7/1, ...
: ...
: m, n, o, 7/20, ...

n********6
发帖数: 1511
4
Because I need to generate report on web, and look for opportunities to generate one recordset by one query.

【在 g***l 的大作中提到】
: 明明是要GROUP BY两次么,为啥用一个QUERY,做样子?
n********6
发帖数: 1511
5
will try.

【在 i****a 的大作中提到】
: try group by brand
: and in the query do case date count
:
: to the customer per vehicle brand, by

g***l
发帖数: 18555
6
不会做两个QUERY JOIN在一起啊,记得用LEFT JOIN,MONTH的在左边

generate one recordset by one query.

【在 n********6 的大作中提到】
: Because I need to generate report on web, and look for opportunities to generate one recordset by one query.
1 (共1页)
进入Database版参与讨论
相关主题
请问个join的问题sql question
做 php 如何发展呢 ?[转载] Can anyone interpret this simple SQL?
这个 query 为什么可以 update multiple rows如何完成这个sql?
SQL求助:两个表各自求Countquestion on nested query
Re: Recordset - I stuck! Help!Re: 求教: Join 两个query (data) tables 出错
问一个简单的Query[转载] strong SQL skills?
Help on Oracle Query急问 hibernate query
query questions有什么优化query的常用方法
相关话题的讨论汇总
话题: ford话题: brand话题: query话题: need话题: chevy