[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

sql state ment i not correct in mysql

(MonthNos*2-1)*Interrest As MiniPay maybe this code not correct


SELECT balanceborow.wid, balanceborow.wname, balanceborow.amout,  CEILING(balanceborow.amout*.02) AS Interrest, balanceborow.DateBalance, balanceborow.amout, Round(DATEDIFF( NOW() , balanceborow.DateBalance)/30, 0) As MonthNos, (MonthNos*2-1)*Interrest As MiniPay
FROM balanceborow
WHERE balanceborow.wid ='$AccNo'
0
teera
Asked:
teera
  • 3
2 Solutions
 
Ashish PatelCommented:
You have to use this way only.


SELECT balanceborow.wid, balanceborow.wname, balanceborow.amout,  CEILING(balanceborow.amout*.02) AS Interrest, balanceborow.DateBalance, balanceborow.amout, Round(DATEDIFF( NOW() , balanceborow.DateBalance)/30, 0) As MonthNos, (Round(DATEDIFF( NOW() , balanceborow.DateBalance)/30, 0)*2-1)*CEILING(balanceborow.amout*.02) As MiniPay
FROM balanceborow
WHERE balanceborow.wid ='$AccNo'
0
 
Ashish PatelCommented:
The alias Interrest and MonthNos are temporary and cannot be used in single select statement, so use the query i gave you above.


Also teera, why dont you close the open items posted earlier which you think are already replied for you.
0
 
Ashish PatelCommented:
Thanks for closing the items posted previously.
0
 
ee_rleeCommented:
you can also do this if you don't want to rewrite the formulas.
SELECT *,(MonthNos*2-1)*Interrest As MiniPay
FROM
(SELECT balanceborow.wid, balanceborow.wname, balanceborow.amout,  CEILING(balanceborow.amout*.02) AS Interrest, balanceborow.DateBalance, balanceborow.amout, Round(DATEDIFF( NOW() , balanceborow.DateBalance)/30, 0) As MonthNos 
FROM balanceborow
WHERE balanceborow.wid ='$AccNo')

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now