Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hiii, i have 2 tables which is pd and fr.
pd contains pamount,pid
meanwhile fr contain pid, month, and frresult.
1pid can have many frresult based on its month, so each pid will have 12 record about frresult from january until december.

i tried to make it but it doesnt work, below is my sql statement:

select pid, case when (pamount<=frrresult)
          then '!'
         end as notification
from pd, fr where  MONTH(Month) = MONTH(GETDATE())


Actually if the pamount in pd table is less equal than frrresult in fr table and the current month is equal to the month in fr table, this notification will come out.

i already input the data in frr table where pid1's frresult for May is less than the pid1's pamount. But when i execute it , there is no any output from it.
is there sth wrong with my code?
please help me. thank you in advanced. :)
Posted
Comments
ZurdoDev 28-May-14 10:27am    
I don't understand the problem.
hahaahahaahahhahahahhahaha 28-May-14 10:37am    
actually each product will have different reorder point for each month. then my sql statement is used to show the alert which will happened when the pamount <= reorderpoint, but it is based on the current actual month. So for example, if this month is May then when i execute the statement the result will show the pid which its pamount <= reorder point for May. sorry for my bad english @@

Hello friend, can you please try the following SQL:

SQL
SELECT PD.PID, '!' AS [Notification]
FROM PD INNER JOIN FR ON PD.PID = FR.PID
WHERE PD.PAMOUNT <= FR.FRRESULT
AND MONTH(FR.MONTH) = MONTH(GETDATE())
 
Share this answer
 
Comments
hahaahahaahahhahahahhahaha 28-May-14 10:45am    
heii, it also does not show any result.@@
i already input the pamount which is lesser then the frresult for month 5 but it still cannot work @@
hahaahahaahahhahahahhahaha 28-May-14 10:51am    
heiii it works actually Deb! thank you so much~
Debabrata_Das 28-May-14 11:01am    
You are welcome! :)
Looks like there is no relation between the tables in your query. Also, where does Month come from? I would expect a sql statement more like this.
SQL
select pid, 
     case when (pamount<=frrresult)
           then '!'
           else NULL
          end as notification
    from pd, fr 
    where pd.pid = fr.pid 
      and MONTH(fr.Month) = MONTH(GETDATE())


Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900