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.
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 qtyFROM 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.productidServer: Msg 170, Level 15, State 1, Line 3Line 3: Incorrect syntax near '='.this is the abvoe error generatedabove is the query by which i m trying to get expiry date of aproduct. 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 themonth nov.,2011 what are the products whose warranty periodcompletes 12 months so that in advance i should be aware thatwarranty does not expire. i may check for forward one month orcurrent month. all dates of target month should compare dateswith 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 problemsSELECT COALESCE(a.COLLATIONNAME,b.Col) AS [Col]FROM Accrual2011_CPPMWWINNER?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 AINNER 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 Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/ |
|
|
|
|
|
|
|