Click here to Skip to main content
15,891,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I have result set like this
productid	proudctname	enterdate	nameoftheday	status
1		colgate		2013/05/01       wednesday	 0
2		santoor		2013/05/01       wednesday	 0
3		rin		2013/05/01       wednesday	 0
4		lux		2013/05/02       Thursday	 0
4		mouse		2013/05/03       friday		 0
null		null	        2013/05/04       satruday	 0
null		null  	        2013/05/05       sunday	         0
5		cellphone	2013/05/06	 monday	 	 0
6		bottle 		2013/05/06	 monday	 	 0
7		books		2013/05/06	 monday	 	 0
null		null		2013/05/07	 tuesday	 1
8		chair		2013/05/08	 wednuesday      0
null		null    	2013/05/09	 Thursday	 1

now i want to update above result set
that is
if status =1
i want to update previous date values
in product id and productname
To get clarification i will give sample output
productid	proudctname	enterdate	nameoftheday	status
1		colgate		2013/05/01       wednesday	 0
2		santoor		2013/05/01       wednesday	 0
3		rin		2013/05/01       wednesday	 0
4		lux		2013/05/02       Thursday	 0
4		mouse		2013/05/03       friday		 0
null		null	        2013/05/04       satruday	 0
null		null  	        2013/05/05       sunday	         0
5		cellphone	2013/05/06	 monday	 	 0
6		bottle 		2013/05/06	 monday	 	 0
7		books		2013/05/06	 monday	 	 0
5or6or7	  cellphone/bottle/books 2013/05/07	 tuesday	 1
8		chair		2013/05/08	 wednuesday      0
8		chair	    	2013/05/09	 Thursday	 1


Could anyone help me out

Regards,
Prakash.ch
Posted
Updated 5-Jun-13 21:23pm
v2

1 solution

Have a look here: sql server filtering data[^]. Exactly the same question and my anser!
 
Share this answer
 
Comments
prakash.chakrala 6-Jun-13 3:54am    
In that solution wherever nulls are available its replacing
Maciej Los 6-Jun-13 4:25am    
Yes, NULL's in productid column are replaced with values based on data from previous date ;)
It's not possible to store 5or6or7 in the "productid" column, because its stores integer values.
prakash.chakrala 6-Jun-13 7:33am    
I need to replace if status=1 only
and 5 or 6 or 7 means not in one column
either 5 or 6 or 7
Maciej Los 6-Jun-13 7:41am    
So... What do you need more? Have you seen my past solution? Have you tried to change it to your needs? What is not understandable?
prakash.chakrala 6-Jun-13 8:05am    
tried but.......

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