由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - SQL 请教
相关主题
请问T-SQL中Group By之后怎么找到特定的recordSQL问题
刚做了70-433一道题,觉得答案有问题纪录查找问题
请教高手,包子谢oracle中如何查询已建立的表结构
问一道sql的面试题啊 自己实在是没想出来Help about a SQL statement
请教一个问题请教一个SQL Query
给大家贡献一个fb面试的sql问题how to display all exsiting indexes and their statistics
partition 表To get the 2nd, 3rd, 4th largest value
如何在oracle8i中得到视图和表的定义?请教比较两个table,找出相同和不同的records
相关话题的讨论汇总
话题: 380话题: 375话题: amount
进入Database版参与讨论
1 (共1页)
i****i
发帖数: 18
1
I have a question about T- SQL language.
I wrote a query to get the SUM of every line's Amount with the same
Initiative Key.
SELECT
[Initiative Key]
,[Amount]
,SUM ([Amount]) OVER (PARTITION BY ([Initiative Key])) AS SUM_AMOUNT
FROM [DataClean].[dbo].['Initiative Donations$']
ORDER BY SUM_AMOUNT DESC
Here is the result,
Initiative Key Amount SUM_AMOUNT
KBERFVSJRZIL 10 380
KBERFVSJRZIL 25 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 25 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 25 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 25 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 25 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
KBERFVSJRZIL 10 380
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
97KB07RMROIK 25 375
but in my final report. I only want to know Initiative Key and SUM_Amount (
removing the duplicates). Is there any way to write those queries in one
file.
Initiative Key SUM_AMOUNT
KBERFVSJRZIL 380
97KB07RMROIK 375
B*****g
发帖数: 34098
2
http://www.w3schools.com/sql/sql_groupby.asp

【在 i****i 的大作中提到】
: I have a question about T- SQL language.
: I wrote a query to get the SUM of every line's Amount with the same
: Initiative Key.
: SELECT
: [Initiative Key]
: ,[Amount]
: ,SUM ([Amount]) OVER (PARTITION BY ([Initiative Key])) AS SUM_AMOUNT
: FROM [DataClean].[dbo].['Initiative Donations$']
: ORDER BY SUM_AMOUNT DESC
: Here is the result,

s**********o
发帖数: 14359
3
你QUERY写错了吧
SELECT
[Initiative Key]
,SUM ([Amount])
FROM [DataClean].[dbo].['Initiative Donations$']
GROUP BY [Initiative Key]
i****i
发帖数: 18
4
Thank you Beijing. It is very easy to use Group By. I always think of
Partition .....

【在 B*****g 的大作中提到】
: http://www.w3schools.com/sql/sql_groupby.asp
i****i
发帖数: 18
5
Thank you very much. It works with Group BY.

【在 s**********o 的大作中提到】
: 你QUERY写错了吧
: SELECT
: [Initiative Key]
: ,SUM ([Amount])
: FROM [DataClean].[dbo].['Initiative Donations$']
: GROUP BY [Initiative Key]

y****w
发帖数: 3747
6
if partition, remove amount, plus distinct.

【在 i****i 的大作中提到】
: I have a question about T- SQL language.
: I wrote a query to get the SUM of every line's Amount with the same
: Initiative Key.
: SELECT
: [Initiative Key]
: ,[Amount]
: ,SUM ([Amount]) OVER (PARTITION BY ([Initiative Key])) AS SUM_AMOUNT
: FROM [DataClean].[dbo].['Initiative Donations$']
: ORDER BY SUM_AMOUNT DESC
: Here is the result,

1 (共1页)
进入Database版参与讨论
相关主题
请教比较两个table,找出相同和不同的records请教一个问题
请教一个有关SQL concat的问题给大家贡献一个fb面试的sql问题
a problem, thank youpartition 表
问一个 SQL combine records问题如何在oracle8i中得到视图和表的定义?
请问T-SQL中Group By之后怎么找到特定的recordSQL问题
刚做了70-433一道题,觉得答案有问题纪录查找问题
请教高手,包子谢oracle中如何查询已建立的表结构
问一道sql的面试题啊 自己实在是没想出来Help about a SQL statement
相关话题的讨论汇总
话题: 380话题: 375话题: amount