Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 12 months calculation for Warranty Calcullation

Author  Topic 

katochkk
Starting Member

1 Post

Posted - 2011-09-16 : 11:53:28
SELECT a.gir_no,a.podate,a.productid,a.description,a.accepted_qty-a.rejected_qty as qty
FROM PU_GIR_ITEM A,PU_GIR_MASTER B WHERE A.GIR_NO=B.GIR_NO and
b.gir_Date =month(dateadd(m,-12,gir_date))=month('2011-10-01'))
and year(dateadd(m,-12,gir_date))=year('2011-10-01') and a.productid
in(select product_id from en_product_master where stock_in_hand > 0 AND STORE_CODE
NOT IN('LBRSTR','CANSTR','CONSTR')and product_id not
in(select product_id from sr_issue)) order by a.productid

Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '='.

this is the abvoe error generated

above is the query by which i m trying to get expiry date of a
product. What i want there is a field

GIR_dATE (This is the date on which product is purchased)

suppose today is 17th Sep. 2011. now i want to check for the
month nov.,2011 what are the products whose warranty period
completes 12 months so that in advance i should be aware that
warranty does not expire. i may check for forward one month or
current month. all dates of target month should compare dates
with GIR_DATE to fetch the prodcuts.

regards,

X002548
Not Just a Number

15586 Posts

Posted - 2011-09-16 : 12:46:05
It helps to format the query so you can SEE the syntax problems



SELECT COALESCE(a.COLLATIONNAME,b.Col) AS [Col]
FROM Accrual2011_CPPMWW
INNER?LEFT?RIGHT? JOIN Accrual2010_CPPMWW
On a.key = b.key

SELECT a.gir_no
,a.podate
,a.productid
,a.description
,a.accepted_qty-a.rejected_qty as qty
FROM #PU_GIR_ITEM A
INNER JOIN #PU_GIR_MASTER B
ON A.GIR_NO=B.GIR_NO
WHERE b.gir_Date =month(dateadd(m,-12,gir_date))=month('2011-10-01'))
AND year(dateadd(m,-12,gir_date))=year('2011-10-01')
AND a.productid in(select product_id
from en_product_master
where stock_in_hand > 0
AND STORE_CODE NOT IN('LBRSTR','CANSTR','CONSTR')
AND product_id not in(select product_id from sr_issue))
order by a.productid


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -