If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > SELECT..IF..ELSE Statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-07, 09:59
janlie87 janlie87 is offline
Registered User
 
Join Date: Dec 2007
Location: College Park, Maryland
Posts: 14
SELECT..IF..ELSE Statement

Hi,

can I execute a Select...If...else Statement with a Pervasive SQL
Vers.8 database? its my first time to use Pervasive... here is my sample code.. pls.. somebody help me modify this..pls..pls..

the if..else..statement wont work...

i badly needed the code..pls somebody..
SELECT
sum(GRNQty) as NEWGT,
if (DOCUMENTTYPE = 4) then sum(InclusivePrice) as Refund,
if (DOCUMENTTYPE = 5) then sum(InclusivePrice) as Adjustments,
sum((QTY*INCLUSIVEPRICE)-REFUND) as Dlysale,
sum((QTY*UNITPRICE)-DISCOUNTAMOUNT) as TOTDISC,
sum(DiscountAmount) as Discount,
sum(TAxAmount) as TAXES,
min(documentnumber) as BEGINV,
max(documentnumber) as ENDINV,
if(ITEMCODE = 'SRVCHARGE') then sum(InclusivePrice) as SERVCHARGE,
if (ITEMCODE = 'OTHRCHARGE') then sum(InclusivePrice) as OTHERCHRGE,
if (TAXTYPE = 0) then sum((Qty*InclusivePrice)-DiscountAmount) as TSL_NX_SAL,
else sum((Qty*InclusivePrice)-DiscountAmount) as TSL_TX_SAL,

if (customercode = 'WALKIN') then sum(QTY*INCLUSIVEPRICE) as CashSales
else sum(QTY*INCLUSIVEPRICE) as ChargeSales
count(*) as TRANCNT,
DATE

From HISTORYLINES WHERE DATE BETWEEN '2007-12-28' AND '2007-12-28' GROUP BY DATE
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On