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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong in this?

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

I am facing an error in below code:

Code:
dt1 = ThisForm.contMaster.Datefromto1._datepicker1.Value 
dt2 = ThisForm.contMaster.Datefromto1._datepicker2.Value

SELECT Somain.sono, Somain.sodate, Somain.pcode, Customer.full_name,;
  Somain.location, CAST(IIF(ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As N(10,2) As amount, ;
  CAST(IIF(ratemin#0,qavalminsd*ratemin,qavalmajsd*ratemaj)) As N(10,2) As delivered,;
  Sosub.qntymaj, Sosub.qntymin, Sosub.ratemaj, Sosub.ratemin,;
  Sosub.qavalmajsd, Sosub.qavalminsd;
 FROM ;
     village!somain ;
    INNER JOIN village!sosub ;
   ON  Somain.sono = Sosub.sono ;
    INNER JOIN village!customer ;
   ON  Somain.pcode = Customer.pcode;
 WHERE  Somain.sodate BETWEEN dt1 AND dt2 ;
 ORDER BY Somain.sono;
 INTO CURSOR soView READWRITE

Please guide me what is missing?

(Note: I want to generate three extra fields like, amount, delivered, balance, so I used cast function)

Thanks

Saif
 
Code:
CAST(IIF(....) AS N(10,2)[b][COLOR=red])[/color][/b] && You should have closing bracket of the CAST() AFTER the type of the field

Borislav Borissov
VFP9 SP2, SQL Server
 
Hi,
Please check the parenthesis

Your code
CAST(IIF(ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As N(10,2) As amount

Correction
CAST(IIF(ratemin#0,qntymin*ratemin,qntymaj*ratemaj) As N(10,2)) As amount

hth

MK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top