小编Tim*_*Tim的帖子

具有多个变量的 T-SQL SELECT

我尝试使用 SQL 语句和 NORTHWIND 数据库获取此输出:

Employee Name:Nancy Davolio
Number of Sales:345
Total Sales:192107.60

Employee Name:Andrew Fuller
Number of Sales:241
Total Sales:166537.75

Employee Name:Janet Leverling
Number of Sales:321
Total Sales:202812.84

Employee Name:Margaret Peacock
Number of Sales:420
Total Sales:232890.85

Employee Name:Steven Buchanan
Number of Sales:117
Total Sales:68792.28
Run Code Online (Sandbox Code Playgroud)

...还有 4 个条目

当我使用这个语句时:

USE Northwind

DECLARE @EmployeeName VARCHAR(40),
        @NumberOfSales INT,
        @TotalSales DECIMAL(10,2),
        @Counter TINYINT = 1,
        @NumEmployees INT = IDENT_CURRENT('dbo.Employees');

WHILE @Counter < @NumEmployees
BEGIN
    --SELECT @EmployeeName = E.FirstName+' '+E.LastName
    --SELECT @NumberOfSales = count(od.OrderID) …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server select while-loop

2
推荐指数
1
解决办法
346
查看次数

标签 统计

select ×1

sql ×1

sql-server ×1

t-sql ×1

while-loop ×1