Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to make a formula!!

Status
Not open for further replies.

steefmen

Programmer
Jan 13, 2005
3
NL
HELP!!! I want to Update a column in SQLServer

I want to make a update, but i tried a lot. But it isnt working.


Has to be something like this :

Update F_omzet
Set kostenplaatscategoriekey = '1'
HAVING (inkoopomzet * 100 / SUM(inkoopomzet) >= 20 )

The table name = F_omzet.
Every row = <NULL> inside of kostenplaatscategoriekey.
The formula is that i want to sum the whole colomn Inkoopomzet thats 100% then i want to know if the inkoopomzet from the row is higher then 20 percent. When its higher I want to make the Colomn kostenplaatscategoriekey 1.

Can somebody help me how i can do this.
Im sorry for my bad english.

Thanx

Steefmen
 
I think that this is what you are looking for.
Code:
declare @inkoopomzet int /*You might need to change this depending on the data in the table.*/
set inkoopomzet = (select sum(inkoopomzet) from F_omzet)
update F_omzet
set kostenplaatscategoriekey = 1
where ((inkoopomzet * 100) / @inkoopomzet) >= 20
Let me know if that works.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top