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!

HELP!!! I want to Update a column in SQLServer

Status
Not open for further replies.

steefmen

Programmer
Jan 13, 2005
3
NL
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
 
Something like this ?
UPDATE F_omzet
SET kostenplaatscategoriekey = '1'
WHERE inkoopomzet >= 0.2 * (SELECT SUM(inkoopomzet) FROM F_omzet)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Please see my response in thread183-984361.

Denny

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

[noevil]
(My very old site)
 
This is working:

UPDATE F_omzet
SET kostenplaatscategoriekey = '1'
WHERE inkoopomzet >= 0.2 * (SELECT SUM(inkoopomzet) FROM F_omzet)

Thanx for the answer but i have this now and i want more. Maybe you can help me with that to.

I want something like this :

UPDATE F_omzet
SET kostenplaatscategoriekey = '1'
WHERE inkoopomzet >= 0.2 * (SELECT SUM(inkoopomzet) FROM F_omzet WHERE Month = Numberofthemonth AND Year = Numberoftheyear)

The problem is that Numberofthemonth and Numberoftheyear are standing in the same table F_omzet.
What i want the SUM of(Inkoopomzet) from every month of one year and then checks if the normal inkoopomzetvalue of the row is bigger then 20% of that month and that year.In the table you have a column year and a colomn month.

I hope someone can help me.
Thanx

Steefmen
 
UPDATE F_omzet A
SET kostenplaatscategoriekey = '1'
WHERE inkoopomzet >= 0.2 * (SELECT SUM(B.inkoopomzet) FROM F_omzet B WHERE B.Month=A.Month AND B.Year=A.Year)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top