行合併我的表像下面如何在SQL甲骨文
PARTICULAR OPENING TRANSACTION ENDING
Expense 5456456 0 0
Expense 0 1232131 0
Expense 0 0 123123
但我希望得到像下面
PARTICULAR OPENING TRANSACTION ENDING
Expense 5456456 1232131 123123
是否有可能的信息,以實現這一目標使用SQL查詢?
行合併我的表像下面如何在SQL甲骨文
PARTICULAR OPENING TRANSACTION ENDING
Expense 5456456 0 0
Expense 0 1232131 0
Expense 0 0 123123
但我希望得到像下面
PARTICULAR OPENING TRANSACTION ENDING
Expense 5456456 1232131 123123
是否有可能的信息,以實現這一目標使用SQL查詢?
這聽起來像你只是想
SELECT particular,
max(opening) opening,
max(transaction) transaction,
max(ending) ending
FROM your_table_name
GROUP BY particular
假設交易,開場和結束時都大於零的只是一排,下面將工作
SELECT
particular
, MAX(opening) as opening
, MAX(transaction) as transaction
, MAX(ending) as ending
FROM
TBL_NAME
GROUP BY particular
在一般情況下,本文檔(的oracle組功能)可能是有用的:http://docs.oracle.com/cd/E17952_01/refman-5.5-en/group-by-functions.html#function_max
你想SUM
它,我猜!
SELECT particular,
SUM(opening) AS total_opening,
SUM(transaction) AS total_transaction,
SUM(ending) AS total_ending
FROM your_table
GROUP BY particular