本文介绍了如何更改表中数据的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我将aantal更改为0时,由于某种原因它会变回5。

有人知道为什么吗?

i想要为aantal填充一个数字然后乘以prijs。



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)





我尝试过:



选择总和(Aantal_consumpties * Prijs)AS prijsbier FROM Bier;



What I have tried:

"select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier";

推荐答案

select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier





您需要的是更新:





What you need is an UPDATE:

UPDATE Bier SET Aantal_consumpties = 5;
select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier;



这篇关于如何更改表中数据的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 11:26