我是SQL新手,我想在Microsoft Visual Studio中使用SQL查詢填充列,其中我有一個從1到24的連續編號。但是,這些編號填充2個條件:按年份,月份分組。用連續編號填充SQL列
突出顯示爲藍色是我想要的輸出:
注:本月整數表示。例如1 = 1月。
目前查詢:
CREATE TABLE [dbo].[upload_STS_data] (
[result_count] INT NOT NULL,
[username] VARCHAR (50) NOT NULL,
[year] INT NOT NULL,
[month] INT NOT NULL,
[Users_acct_id] INT NOT NULL,
[upload_id] INT IDENTITY (1, 1) NOT NULL,
PRIMARY KEY CLUSTERED ([upload_id] ASC),
CONSTRAINT [fk_upload_STS_data_Users1] FOREIGN KEY ([Users_acct_id]) REFERENCES [dbo].[Users] ([acct_id])
);
GO
CREATE NONCLUSTERED INDEX [fk_upload_STS_data_Users1_idx]
ON [dbo].[upload_STS_data]([Users_acct_id] ASC);
我怎樣才能做到這一點?
完成:) @GordonLinoff – Vannessa