Source is Sales Table:
Sno Prod Sales Sales_Amount
1 A 10 2000
2 A 20 1000
3 C 10 3000
4 D 30 4000
5 A 20 1000

Target :
Sales_Count T_Sales_Amt Sales_Count(A) T_Sales_Amt(A)
90 11000 50 4000

In single query, pls tell me.

Answer Posted / welcomeashwin

SELECT
T1.SALES_COUNT, T1.T_SALES_AMT,
T2.SALES_COUNT_A, T2.T_SALES_AMT_A
FROM
(SELECT SUM(SALES) SALES_COUNT,
SUM(SALES_AMOUNT) T_SALES_AMT
FROM SALES)T1,
(SELECT SUM(SALES) SALES_COUNT_A,
SUM(SALES_AMOUNT) T_SALES_AMT_A
FROM SALES
WHERE PROD='A' GROUP BY PROD)T2

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which are the different character-manipulation functions in sql?

719


What is delimiter in pl sql?

743


How do I order by ascending in sql?

741


What is null in pl/sql?

812


Explain the difference between 'between' & 'and' operators in sql

724






What are triggers and its uses?

790


what is a stored procedure? : Sql dba

783


Is postgresql a server?

736


What is clustered index in sql?

785


What is cross join sql?

684


how to analyze tables with 'mysqlcheck'? : Sql dba

720


define data blocks ? : Sql dba

736


What is schema in sql?

683


Is pl sql a programming language?

716


What can sql server reporting services do?

793