Microsoft
Software
Hardware
Network
Question : SQL query
I am writting a SQL query. Below is the sample table. The result i want is for each customer, difference of sum of by and sum of sell.
Table:
customer trtype amount
0001 by 10000
0001 by 2000
0001 by 500
0001 sl 3000
0001 sl 2000
0002 by 60000
0002 by 4000
0002 by 500
0002 sl 3000
0002 sl 2000
example:
0001 : (10000+2000+500) - (3000+2000) = 12500-5000 = 7500
0002 : (60000+4000+500)-(3000+200
0) = 64500-5000 = 59500
Result should be
0001 - 7500
0002 - 59500
Answer : SQL query
try this
Select A.customer, B.Name, sum(case when trtype='by' then amount else -amount end)
from tablename A join customerTable B
on A.customer = b.code
group by A.customer, B.Name
Random Solutions
Set up ISAPI module on IIS7
I am trying to add an edit, delete function to an existing gridview
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI<wbr />_AS" and "Latin1_General_CI_AS" in the equal to operation
How can I increase the size of the C drive on a new Dell server
After_Update Event not firing
Add New REG_DWORD type Hexadecimal base Key in Registry using VB6
UML Reverse Engineer Visual Studio 2008 and Visio 2007
Can not create outlook data file
Excel Question
IRR function - project with all negative periods