Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
everytime when i change aantal to 0 it changes back to 5 for some reason.
does someone know why?
i want to fill a number for aantal and then multiply it with "prijs".

bierid aantal  prijs
1	5	2
2	0	2
NULL	NULL	NULL

CREATE TABLE [dbo].[Bier] (
    [BierId]             INT IDENTITY (1, 1) NOT NULL,
    [Aantal_consumpties] INT NULL ,
    [Prijs]              INT NOT NULL,
    PRIMARY KEY CLUSTERED ([BierId] ASC)


What I have tried:

"select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier";
Posted
Updated 5-Jan-18 7:24am
v3

You do not change the value by doing

SQL
select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier


What you need is an UPDATE:

SQL
UPDATE Bier SET Aantal_consumpties = 5;
select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier;
 
Share this answer
 
Comments
Leo Chapiro 5-Jan-18 11:10am    
I can not solve all your problems, dude. The answer refers to your question about "how to change a value". If it helps, don't hesitate to mark it as accepted.
Maciej Los 7-Jan-18 7:30am    
Short And To The Point!
5ed!
Leo Chapiro 8-Jan-18 5:20am    
Thanks a lot, Maciej!
You really need to spend some time here [click][^]. This is a rather friendly environment where you can learn-by-doing.

It's much easier, especially in the long run, to just learn how to do basic SQL queries.
 
Share this answer
 

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