GVKun编程网logo

SQL计算成功和失败的条纹(sql计算成功和失败的条纹是什么)

16

在本文中,我们将带你了解SQL计算成功和失败的条纹在这篇文章中,我们将为您详细介绍SQL计算成功和失败的条纹的方方面面,并解答sql计算成功和失败的条纹是什么常见的疑惑,同时我们还将给您一些技巧,以帮

在本文中,我们将带你了解SQL计算成功和失败的条纹在这篇文章中,我们将为您详细介绍SQL计算成功和失败的条纹的方方面面,并解答sql计算成功和失败的条纹是什么常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的ajax的另一种成功和失败回调函数、C#编译器的泛型,继承和失败的方法解析、centos 拨号pptp在拨号成功和拨号失败的时候脚本处理!!!非常重要、gruntjs – Grunt watch – 检测任务的成功和失败

本文目录一览:

SQL计算成功和失败的条纹(sql计算成功和失败的条纹是什么)

SQL计算成功和失败的条纹(sql计算成功和失败的条纹是什么)

如果我有一个如下所示的SQL表,该如何计算当前的赢或输连胜(以及按季节对赢/输连胜进行分组/重置)。我想更新表并为每条记录填写条纹。

因此,对于#1,条纹将为“ -1”,#2将为“ 1”,#3将为“ 2”,但是一旦我们降至#7,它将再次重置为“
1”。(+1表示“赢得1场比赛”,-1表示“失去1场比赛”,依此类推。)

ID    team    date         Result    season     streak1     76ers   2000-01-01   Loss      2000       Null2     76ers   2000-01-05   Win       2000       Null3     76ers   2000-01-08   Win       2000       Null4     Lakers  2000-01-03   Loss      2000       Null5     Lakers  2000-01-07   Loss      2000       Null6     Lakers  2000-01-01   Win       2000       Null7     76ers   2002-03-01   Win       2001       Null8     76ers   2002-03-05   Win       2001       Null9     76ers   2002-03-08   Loss      2001       Null10    Lakers  2002-03-03   Loss      2001       Null11    Lakers  2002-03-07   Loss      2001       Null12    Lakers  2002-03-01   Win       2001       Null

答案1

小编典典

对于每个游戏,计算与之前结果相同的游戏,这样就不会有中间结果相反的游戏。将结果存储在临时表中:

CREATE TEMPORARY TABLE STREAK_TABLESELECT    ID,    (        SELECT 1 + COUNT(*)                 -- Earlier games with the same result, team and season.        FROM YOUR_TABLE T2        WHERE            T1.Result = T2.Result            AND T1.team = T2.team            AND T1.season = T2.season            AND T1.date > T2.date            AND NOT EXISTS (                SELECT *                    -- The games in between, with the same team and season but opposite result.                FROM YOUR_TABLE T3                WHERE                    T2.Result <> T3.Result                    AND T1.team = T3.team                    AND T1.season = T3.season                    AND T3.date BETWEEN T2.date AND T1.date            )    ) SFROM YOUR_TABLE T1

然后,更新原始表(并消除该过程中的丢失条纹):

UPDATE YOUR_TABLESET streak = (    SELECT CASE Result WHEN ''Win'' THEN S ELSE -S END    FROM STREAK_TABLE    WHERE STREAK_TABLE.ID = YOUR_TABLE.ID)

最后,清理临时表:

DROP TABLE STREAK_TABLE

ajax的另一种成功和失败回调函数

ajax的另一种成功和失败回调函数

第一种:

function engline(){
    var oldmsg = $(''#lineso'').val()
    if(oldmsg == null || oldmsg == '''' || oldmsg == undefined){
        alert(''input content Please'')
    }else{
    //alert(oldmsg)
        $.ajax({
            url:"http://127.0.0.1:8888/engline",
            data : {''msg'':oldmsg},
            type : ''GET'',
            timeout : 3000,
            // 成功回调
            success: function(data){
                if(data){
                    $(''#linest'').val(data)
                }else{
                    alert(''not result'')
                }
            },    
            //失败回调
            error: function(XMLHttpRequest, textStatus, errorThrown){
                //查看错误信息
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            }
        })
    };
}

第二种:

function engline(){
    var oldmsg = $(''#lineso'').val()
    if(oldmsg == null || oldmsg == '''' || oldmsg == undefined){
        alert(''input content Please'')
    }else{
    //alert(oldmsg)
        $.ajax({
            url:"http://127.0.0.1:8888/engline",
            data : {''msg'':oldmsg},
            type : ''GET'',
            timeout : 3000,
            //成功回调
        }).done(function(data){
            if(data){
                $(''#linest'').val(data)
            }else{
                alert(''not result'')
            }    
            //失败回调
        }).fail(function(XMLHttpRequest, textStatus, errorThrown){
            alert(XMLHttpRequest.status);
            alert(XMLHttpRequest.readyState);
            alert(textStatus);
        })
    };
}

 

C#编译器的泛型,继承和失败的方法解析

C#编译器的泛型,继承和失败的方法解析

我今天碰到了编辑问题,这让我感到困惑.考虑这两个容器类.
public class BaseContainer<T> : IEnumerable<T>
{
    public void DoStuff(T item) { throw new NotImplementedException(); }

    public IEnumerator<T> GetEnumerator() { }
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { }
}
public class Container<T> : BaseContainer<T>
{
    public void DoStuff(IEnumerable<T> collection) { }

    public void DoStuff <Tother>(IEnumerable<Tother> collection)
        where Tother: T
    {
    }
}

前者定义了DoStuff(T项),后者用DoStuff< Tother>(IEnumerable< Tother>)重载它,专门用于解决缺少covariance/contravariance的C#(直到4听到).

这段代码

Container<string> c = new Container<string>();
c.DoStuff("Hello World");

遇到一个相当奇怪的编译错误.注意缺少< char>从方法调用.

The type ‘char’ cannot be used as type parameter ‘Tother’ in the generic type or method ‘Container.DoStuff(System.Collections.Generic.IEnumerable)’. There is no Boxing conversion from ‘char’ to ‘string’.

本质上,编译器试图将我对DoStuff(字符串)的调用阻塞到Container.DoStuff< char>(IEnumerable< char>)中,因为字符串实现了IEnumerable< char>,而不是使用BaseContainer.DoStuff(字符串).

我发现进行此编译的唯一方法是将DoStuff(T)添加到派生类

public class Container<T> : BaseContainer<T>
{
    public new void DoStuff(T item) { base.DoStuff(item); }

    public void DoStuff(IEnumerable<T> collection) { }

    public void DoStuff <Tother>(IEnumerable<Tother> collection)
        where Tother: T
    {
    }
}

为什么编译器试图将字符串堵塞为IEnumerable< char> 1)它知道它不能(假设存在编译错误)和2)它在基类中有一个编译好的方法?我是否误解了C#中的泛型或虚拟方法的东西?除了向Container添加新的DoStuff(T项)之外,还有其他修复方法吗?

解决方法

编辑

好的……我想我现在看到你的困惑了.您可能希望DoStuff(字符串)将参数保留为字符串,然后首先查找BaseClass方法列表以查找合适的签名,并且尝试将参数转换为其他类型时失败.

但它发生了反过来……相反,Container.DoStuff(字符串)去了,嗯“theres一个基类方法适合该法案,但我将转换为IEnumerable并对可用的内容进行心脏病发作在当前的班级而不是……

嗯……我肯定Jon或marc能够在这一点上用特定的C#Spec段落来报道这个特殊的角落案例

原版的

两种方法都期望IEnumerable Collection

你正在传递一个单独的字符串.

编译器正在接受该字符串并继续

Ok,I have a string,Both methods
expect an IEnumerable<T>,So I’ll
turn this string into an
IEnumerable<char>… Done

Right,Check the first method…
hmmm… this class is a
Container<string> but I have an
IEnumerable<char> so that’s not right.

Check the second method,hmmm…. I
have an IEnumerable<char> but char
doesn’t implement string so that’s
not right either.

编译器错误

那么修复是什么,它完全取决于你想要实现的目标…以下两个都是有效的,基本上,你的类型用法在你的化身中是不正确的.

Container<char> c1 = new Container<char>();
        c1.DoStuff("Hello World");

        Container<string> c2 = new Container<string>();
        c2.DoStuff(new List<string>() { "Hello","World" });

centos 拨号pptp在拨号成功和拨号失败的时候脚本处理!!!非常重要

centos 拨号pptp在拨号成功和拨号失败的时候脚本处理!!!非常重要

/etc/ppp/ip-up

PPP链接成功时都会执行一下.

/etc/ppp/ip-down

ppp链路断开时都会执行一下.




gruntjs – Grunt watch – 检测任务的成功和失败

gruntjs – Grunt watch – 检测任务的成功和失败

UPDATE

我目前正在使用类似于here所述的解决方案来进行错误通知,以及下面的“当前解决方法”(不修改grunt force选项)以获取成功通知.

原始问题

我无法确定grunt-contrib-watch运行的子任务何时完成(成功与否).

具体来说,我正在使用grunt-contrib-coffee和grunt watch来编译我们改变的CoffeeScript文件.编译工作正常.

我想做的是通知自己编译的状态.这是我尝试过的(CS中的所有代码):

目前的解决方法

来自SO问题(How can I make a Grunt task fail if one of its sub tasks fail?)

我不喜欢的是:设置和恢复全局选项似乎很笨拙,特别是因为它发生在不同的任务/事件处理程序中.另外,我每次都要删除目标文件.

如果没有设置全局选项,我可以通知一个成功的编译,这很好,但我也想通知一个失败的编译.

grunt.initConfig
  watch: 
    options: nospawn: true
    coffee: 
      files: '<%= coffee.dev.cwd %>/<%= coffee.dev.src %>'
      options: 
        events: ['changed','added']
  coffee:
    dev: 
      expand: true
      cwd: 'app'
      src: '**/*.coffee'
      dest: 'public'
      ext: '.js'

grunt.registerTask 'completedCompile',(srcFilePath,destFilePath) ->
  grunt.option 'force',false
  if grunt.file.exists( destFilePath )
    # notify success
  else 
    # notify failure

grunt.event.on 'watch',(action,filepath) ->
  if grunt.file.isMatch grunt.config('watch.coffee.files'),filepath
    filepath = # compose source filepath from config options (omitted)
    dest     = # compose destination filepath from config options (omitted)

    if grunt.file.exists( dest )
      grunt.file.delete dest   # delete the destination file so we can tell in 'completedCompile' whether or not 'coffee:dev' was successful

    grunt.option 'force',true   # needed so 'completedCompile' runs even if 'coffee:dev' fails
    grunt.config 'coffee.dev.src',filepath   # compile just the one file,not all watched files
    grunt.task.run 'coffee:dev'
    grunt.task.run 'completedCompile:'+filepath+':'+dest   # call 'completedCompile' task with args

另一个选择(这么慢)

正如另一个SO问题(Gruntfile getting error codes from programs serially)所建议的那样,我使用了grunt.util.spawn.

这很有用,但速度很慢(每次保存CS文件时都会有几秒钟).

grunt.event.on 'watch',filepath
    filepath = # compose source filepath from config options (omitted)
    dest     = # compose destination filepath from config options (omitted)

    if grunt.file.exists( dest )
      grunt.file.delete dest   # delete the destination file so we can tell in 'completedCompile' whether or not 'coffee:dev' was successful

    grunt.util.spawn {
      grunt: true # use grunt to spawn
      args: ['coffee:dev']
      options: { stdio: 'inherit' } # print to same stdout
    },-> # coffee:dev finished
      if grunt.file.exists( dest )
        # notify success
      else 
        # notify error

其他尝试

我尝试了很多东西.

>如果先前的编译失败,则grunt.fail.errorcount(在’completedCompile’任务中使用时)不为零. (手动将其重置为零是否安全?如果是,我不必每次都删除dest文件.)即便如此,这需要将全局选项’force’设置为true.
>任何涉及在grunt.initConfig中指定’watch.coffee.tasks’选项的内容都不起作用,因为’coffee’dev’任务在’watch’事件处理程序完成后运行.
> grunt.task.current当然总是指’watch’任务

如果你已经做到这一点,感谢阅读:).

解决方法

我也遇到了同样的问题,试图弄清楚监视子任务何时完成.

部分问题似乎是Watch默认情况下会生成一个新的Grunt进程来运行子任务.因此,您的主要Grunt流程将无法了解完成的任务.您可以设置’nospawn’,但这并没有多大帮助,因为手表不会暴露子任务本身.

我最接近的就是使用Grunt.util.hooker(受Grunt Notify启发)在Grunt失败’报告’方法被调用时作出反应.

grunt.util.hooker.hook(grunt.fail,'report',function(){});

但是,这不包含有关已完成的实际任务的信息,如果您想根据监视任务中的特定子任务执行某些操作,这将非常有用.

看看Grunt Watch github,似乎有一些牵引力来实现完整/失败事件:
https://github.com/gruntjs/grunt-contrib-watch/issues/131

今天关于SQL计算成功和失败的条纹sql计算成功和失败的条纹是什么的分享就到这里,希望大家有所收获,若想了解更多关于ajax的另一种成功和失败回调函数、C#编译器的泛型,继承和失败的方法解析、centos 拨号pptp在拨号成功和拨号失败的时候脚本处理!!!非常重要、gruntjs – Grunt watch – 检测任务的成功和失败等相关知识,可以在本站进行查询。

本文标签: