小编Tan*_*ner的帖子

C++ 函数'remainder' 和'fmod' 之间的区别?

最近我遇到了需要fmod()在 C++ 中使用函数来计算两个长双操作数的模数。

但我也看到有一些 C++“剩余”函数可以完成几乎相同的工作。

这两个函数有什么区别?

c++ c++11

6
推荐指数
2
解决办法
3993
查看次数

MySQL中的timestampdiff()是否等同于SQL Server中的datediff()?

我正在努力将功能从SQL Server 2000迁移到MySQL.

在SQL Server 2000中执行以下语句,输出为109.

SELECT DATEDIFF(wk,'2012-09-01','2014-10-01') AS NoOfWeekends1
Run Code Online (Sandbox Code Playgroud)

在mysql中使用的等效查询timestampdiff()代替datediff并将输出提供为108.

SELECT TIMESTAMPDIFF(WEEK, '2012-09-01', '2014-10-01') AS NoOfWeekends1
Run Code Online (Sandbox Code Playgroud)

我需要输出在MySQL中执行时匹配,因此返回109.

mysql sql-server datediff sql-server-2000

6
推荐指数
1
解决办法
9368
查看次数

一些bootstrap glyphicons没有加载

我有一个WordPress主题,我正在使用Bootstrap Sass源构建.样式是有效的,但大多数字形不是(只有星号和加号).我正在编译我的Bootstrap到style.css相对于那个,有一个文件夹调用fonts它来保存glyphicons(我设置$icon-font-path: "fonts/";)这是我编译的一个片段style.css,表明字体路径是正确的:

@font-face { font-family: 'Glyphicons Halflings'; src: url("fonts/glyphicons-halflings-regular.eot"); src: url("fonts/glyphicons-halflings-regular.eot?#iefix") format("embedded-opentype"), url("fonts/glyphicons-halflings-regular.woff2") format("woff2"), url("fonts/glyphicons-halflings-regular.woff") format("woff"), url("fonts/glyphicons-halflings-regular.ttf") format("truetype"), url("fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular") format("svg"); }
.glyphicon { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons Halflings'; font-style: normal; font-weight: normal; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
Run Code Online (Sandbox Code Playgroud)

例如,这些工作:

<span class="glyphicon glyphicon-asterisk" aria-hidden="true"></span>
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
Run Code Online (Sandbox Code Playgroud)

但这些不是:

<span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>
<span class="glyphicon glyphicon-heart" aria-hidden="true"></span>
Run Code Online (Sandbox Code Playgroud)

这是一个glyphicon类的片段:

.glyphicon-asterisk:before { content: "\2a"; }
.glyphicon-plus:before { content: "\2b"; …
Run Code Online (Sandbox Code Playgroud)

wordpress sass twitter-bootstrap bootstrap-sass glyphicons

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

四分位间距-下限,上限和中位数

我正在尝试根据可以是任意长度的数字数组来计算四分位数范围

1,  1,  5,  6,  7,  8,  2,  4,  7,  9,  9,  9,  9
Run Code Online (Sandbox Code Playgroud)

我需要从这个四分位数范围得出的值是:

  • 上四分位
  • 中位数
  • 下四分位数

如果我将上述数字数组转储到Microsoft Excel(列A:M)中,则可以使用以下公式:

  • =QUARTILE.INC(A1:M1,1)
  • =QUARTILE.INC(A1:M1,2)
  • =QUARTILE.INC(A1:M1,3)

得到我的答案:

  • 4
  • 7
  • 9

我现在需要在SQL Server或VB.NET中计算这3个值。我可以使用任何一种语言的任何格式或对象来获取数组值,但是找不到像QUARTILE.INCExcel所具有的函数那样存在的任何函数。

有谁知道如何在SQL Server或VB.NET中实现此目标?

vb.net sql-server excel

6
推荐指数
1
解决办法
1万
查看次数

Knockout 3.2组件数据上下文

我正在使用Knockout 3.2和新的组件系统.我正在尝试使用包含子组件的组件.

Home Page (component - with HomePageViewModel) NewsFeed1 (component with HomePageViewModel.NewsFeedViewModel1) NewsFeed2 (component with HomePageViewModel.NewsFeedViewModel2)

HomePageViewModel

var viewModel = (function () {
    function viewModel() {
        this.message = ko.observable("Welcome to DKT!");
        this.newsFeedViewModel = new gr.viewModel();
        this.newsFeedViewModel2 = new gr.viewModel();
        this.newsFeedViewModel.message("Message 1");
        this.newsFeedViewModel2.message("Message 2");
    }
    return viewModel;
})();
Run Code Online (Sandbox Code Playgroud)

NewsFeedViewModel

var viewModel = (function () {
    function viewModel() {
        this.message = ko.observable("This is the profile!");
    }
    return viewModel;
})();
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,HomePageViewModel包含了两者NewsFeedViewModel.我现在希望能够将这些作为我的两个组件的DataContext/BindingContext使用,但这似乎不起作用.

Home.html中

<news-feed data-bind="newsFeedViewModel"></news-feed>
<news-feed data-bind="newsFeedViewModel2"></news-feed>
Run Code Online (Sandbox Code Playgroud)

这两个组件都不使用ViewModel,HomePageViewModel而是使用新的 …

data-binding datacontext knockout.js knockout-components

5
推荐指数
1
解决办法
2908
查看次数

在SQL Server中显示摘要结果

我有以下表格结构也提到我的预期输出请帮我查询,因为我不太了解SQL查询

表1:类别

Name      CatId   
 A         1   
 B         2   
 C         3   
Run Code Online (Sandbox Code Playgroud)

表2:Emp详细信息

FName      Id   Dob           CatId
Pratik      1   1958-04-06      2
Praveen     3   1972-05-12      1 
Nilesh      2   1990-12-12      2
Run Code Online (Sandbox Code Playgroud)

到目前为止,我试图获得所有结果:

SELECT A.Code,A.EmpName,A.DOB,B.cname 
FROM EMPMASTER A
JOIN CATMASTER B ON A.cCode = B.ccode AND A.Compcode = B.CompCode
WHERE A.compcode = 'C0001' AND  month(A.DOB) >= 1 
      AND MONTH(A.DOB) <= 12  AND A.termflag='L' 
ORDER BY  A.DOB 
Run Code Online (Sandbox Code Playgroud)

但我的问题是,我还希望显示摘要结果

预期摘要输出:

Grouping           No Of Employees
 A                     1
 B                     2
 C                     0
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2008 sql-server-2008-r2

5
推荐指数
1
解决办法
383
查看次数

在SQL Server中查询复杂的JSON-过滤对象数组

我在将Msft Sql Server中的JSON函数啮合在一起时遇到问题。我有一个表,用于存储复杂的JSON结构,并且需要提取对象数组的子集。

例如,我制作了一个简单的脚本,该脚本创建一个表并用一些记录填充该表:

CREATE TABLE JsonData ( CompanyId int IDENTITY(1,1) NOT NULL, Name varchar(50) NOT NULL, Json varchar(max) NOT NULL)

INSERT INTO JsonData (Name, Json) VALUES ('Company A', '{"Sector":"Food/Bev","EmployeeCount":105,"Address":{"Address1":"88 Oak Ave","Address2":"","City":"Madison","State":"WI","Zip":"11223"},"Vehicles":[{"Make":"Toyota","Model":"Camry","Year":2013,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2017-04-01"},{"Desc":"Oil change","PerformedOn":"2017-08-01"}]},{"Make":"Ford","Model":"F150","Year":2010,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2015-01-01"}]},{"Make":"Honda","Model":"Odyssey","Year":2010,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2013-01-01"},{"Desc":"Oil change","PerformedOn":"2014-01-01"}]}]}');
INSERT INTO JsonData (Name, Json) VALUES ('Company B', '{"Sector":"Plastics","EmployeeCount":853,"Address":{"Address1":"100 Main St","Address2":"","City":"Anchorage","State":"AK","Zip":"56432"},"Vehicles":[{"Make":"Ford","Model":"F150","Year":2003,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2017-01-01"},{"Desc":"Tire rotation","PerformedOn":"2017-01-01"},{"Desc":"Brake inspection","PerformedOn":"2017-02-01"}]},{"Make":"Ford","Model":"F150","Year":2008,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2017-01-01"}]},{"Make":"Volkswagen","Model":"Jetta","Year":2010,"Maintenance":[]}]}');
INSERT INTO JsonData (Name, Json) VALUES ('Company C', '{"Sector":"Plastics","EmployeeCount":50,"Address":{"Address1":"99 Pine St","Address2":"","City":"Dallas","State":"TX","Zip":"33443"},"Vehicles":[{"Make":"Pontiac","Model":"Fiero","Year":1998,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2010-04-01"},{"Desc":"Oil change","PerformedOn":"2000-08-01"}]},{"Make":"Chevy","Model":"Silverado","Year":2008,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2010-01-01"}]},{"Make":"Honda","Model":"Odyssey","Year":2014,"Maintenance":[{"Desc":"Oil change","PerformedOn":"2015-04-01"},{"Desc":"Oil change","PerformedOn":"2015-09-01"}]}]}');
Run Code Online (Sandbox Code Playgroud)

我正在尝试获取福特公司B公司车辆的清单。我的想法是获取公司B的记录,然后解析json以获取Make ='Ford'的Vehicles数组。该脚本有效,但是确实很笨拙。

在我看来,这应该全部汇总为一个声明。

DECLARE @vehicJson varchar(max);
SELECT @vehicJson = '{ "Vehicles": ' …
Run Code Online (Sandbox Code Playgroud)

sql-server sql-server-2016 sql-server-json

5
推荐指数
1
解决办法
2910
查看次数

Sql组由最新的重复字段组成

我甚至不知道这个问题的好标题是什么.

但是我有一张桌子:

create table trans 
(
    [transid] INT          IDENTITY (1, 1) NOT NULL,
    [customerid] int not null,
    [points] decimal(10,2) not null,
    [date] datetime not null
)
Run Code Online (Sandbox Code Playgroud)

和记录:

--cus1
INSERT INTO trans ( customerid , points , date )
VALUES ( 1, 10, '2016-01-01' ) , ( 1, 20, '2017-02-01' ) , ( 1, 22, '2017-03-01' ) ,
       ( 1, 24, '2018-02-01' ) , ( 1, 50, '2018-02-25' ) , ( 2, 44, '2016-02-01' ) ,
       ( 2, 20, '2017-02-01' ) …
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2016

5
推荐指数
1
解决办法
93
查看次数

无法在knockout 3.2中使用自定义组件传递变量

我正在努力推进淘汰赛3.2中的自定义组件.如果我使用预定义的参数,一切都很好.例如,这是jsFiddle.

但是当我从我的视图模型传递参数时(我已经阅读了如何在这里做)我没有得到任何东西:jsFiddle.我究竟做错了什么?

这是我的js代码:

ko.components.register('pagination', {
    viewModel: function (params) {
        var self = this;
        this.page = ko.observable(params.page);
        this.max = ko.observable(params.max);

        this.list = ko.pureComputed(function () {
            var a = self.page(),
                list = [],
                min = a - 2 < 1 ? 1 : a - 2,
                max = a + 2 > self.max() ? self.max() : a + 2;

            for (var i = min; i <= max; i++) {
                list.push(i);
            }
            return ko.observableArray(list);
        });

        this.callback = …
Run Code Online (Sandbox Code Playgroud)

knockout.js knockout-3.0 knockout-components

4
推荐指数
1
解决办法
2788
查看次数

基于逗号分隔值连接表

如何连接两个表,其中一个表在一列中有多个逗号分隔值,引用id另一列?

第一桌

Name    | Course Id
====================
Zishan  | 1,2,3                                           
Ellen   | 2,3,4                
Run Code Online (Sandbox Code Playgroud)

第二张桌子

course id | course name 
=======================
   1      |  java
   2      |  C++
   3      |  oracle
   4      |  dot net
Run Code Online (Sandbox Code Playgroud)

sql-server

4
推荐指数
1
解决办法
1万
查看次数