× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi
I am looking for SQL to add additional two columns(positive and negative) to my current file and populate them as below.
Any quick help is appreciated.
 
positive = QUANTITY WHEN FLAG =1
negative = 0       WHEN FLAG  =1
positive = 0       WHEN FLAG =2
negative = QUANTITY WHEN FLAG =2
 
CURRENT:
=======
ACCT brch TYC     yrm     flag QUANTITY
ABCPQ 1     21     201312 2     645   
ABCPQ 1     25     201312 1     1920   
ABCPQ 1     26     201312 2     192   
1234C 1     25     201312 1     144   
       
       
EXPECTED:
========       
       
ACCT     brch TYC yrm     flag QUANTITY positive negative
             
             
ABCPQ     1     21 201312     2  645       0      645
ABCPQ     1     25 201312     1  1920      1920    0
ABCPQ     1     26 201312     2  192          0    192
1234C     1     25 201312     1  144       144     0CURRENT:
=======
ACCT brch TYC yrm flag QUANTITY

ABCPQ 1 21 201312 2 645
ABCPQ 1 25 201312 1 1920
ABCPQ 1 26 201312 2 192
1234C 1 25 201312 1 144


EXPECTED:
========

ACCT brch TYC yrm flag QUANTITY positive negative


ABCPQ 1 21 201312 2 645 0 645
ABCPQ 1 25 201312 1 1920 1920 0
ABCPQ 1 26 201312 2 192 0 192
1234C 1 25 201312 1 144 144 0

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.