Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql question

Status
Not open for further replies.

TRYP

Programmer
Jun 20, 2000
136
US
Access query question,
if i have a table with colums A , B and C ...
A is text
B is a boolean
C is a long

how would i write the SQL to do get following 2 Columns
display unique A's
sum column C
BUT if B is false then C is a negative number

Example...
ColA ColB ColC
CompanyA True 10
CompanyB True 12
CompanyB True 12
CompanyC True 20
CompanyA False 5

Then i would need this result set
CompanyA 5
CompanyB 24
CompanyC 20

HELP ! :)
-tryp
 


Hi,
Code:
SELECT A, Sum(iif(B,1,-1)*c)
FROM MyTable
Group By A

Skip,

[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue]
 
rightgeous !!
ty ty
been a while since i used sql
ty ty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top