小编Din*_*aud的帖子

如何按顺序对相同的值进行分组

我正在尝试按顺序对数据进行分组。我有下表:

id  num
-------
1   1
2   1
3   1
4   2
5   1
6   2
7   2
8   4
9   4
10  4
Run Code Online (Sandbox Code Playgroud)

我需要 SQL 查询来输出以下内容:

num       count(num)
-------------------    
1          3    
2          1    
1          1    
2          2    
4          3 
Run Code Online (Sandbox Code Playgroud)

样本数据:

select * into #temp 
from (
    select 1 as id, 1 as num union all
    select 2,  1  union all
    select 3,  1  union all
    select 4,  2  union all
    select 5,  1  union all
    select 6,  2  union …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server window-functions gaps-and-islands

0
推荐指数
1
解决办法
256
查看次数

C#中如何继承两个或多个具有相同方法名的接口,并且派生类应该进一步继承到另一个类中

我们如何在类中实现两个或多个具有相同方法名称的接口,并且派生类应该进一步继承到具有相同方法的新类中。

using System;  

interface A  
{  
    void Hello();  
}  

interface B  
{  
    void Hello();  
}  

class Test : A, B  
{  
    void A.Hello()  
    {  
        Console.WriteLine("Test Hello-A");  
    } 

    void B.Hello()  
    {  
        Console.WriteLine("Test Hello-B");  
    }  
}  

class Demo : Test {
   //what will be the code to override Hello method
}

public class MainClass  
{  
    public static void Main()  
    {  
        //How can we access the Hello method of Test & Demo class  
    }  
}
Run Code Online (Sandbox Code Playgroud)

c# inheritance overriding interface

-1
推荐指数
1
解决办法
64
查看次数