logo
Tags down

shadow

Select records that appear twice, with a slight difference


By : user2175237
Date : October 15 2020, 08:10 PM
fixed the issue. Will look into that further I have quick question on a select I'm trying to do. , Using aggregation:
code :
SELECT
    Name,
    Surname
FROM yourTable
GROUP BY
    Name,
    Surname
HAVING
    COUNT(CASE WHEN Passed IN ('C', 'Y') THEN 1 END) > 0 AND
    COUNT(CASE WHEN Passed IN ('N') THEN 1 END) > 0;


Share : facebook icon twitter icon

select records according to the difference between records R


By : Dan George
Date : March 29 2020, 07:55 AM
Does that help I hope someone could suggest me something for this "problem", because I really don't know how to proceed... Well, my data are like this
code :
data[ave(data$time, data$site, FUN = function(x){c(61, diff(x)) > 60}) == 1, ]

#   site time
# 1    A  100
# 2    A  180
# 3    A  245
# 4    B    5
# 6    B  130
# 7    C   70
keep <- as.logical(ave(data$time, data$site, FUN = function(x){
  c(TRUE, cumsum(diff(x)) > 60)
}))

data[keep, ]

#   site time
# 1    A  100
# 2    A  180
# 3    A  245
# 4    B    5
# 6    B  130
# 7    C   70
# 9    C  160

How to share records structure between projects, with slight variations?


By : Ruslan
Date : March 29 2020, 07:55 AM
With these it helps Easy solution is to keep the data structure and related functions shared between both projects and add additional arrays that contain additional data, specific to each project. It will bring slightly more work to use extra arrays, but will keep shared code really shared.
So, instead of new classes or IFDefs, as proposed in other anwers, a simple extra arrays that link to main data are best option for the problem:
code :
// shared main data through both projects
TData1 = record
  A:string;
  B:integer;
  C:word;
  ...
end;

Data1:TArray<TData1>;

// additional in Project 2
TDataExtra = record
  DataIdx:integer;// link to TData1
  XMLNode:TXMLNode;
  ...
end; 

DataExtras:TArray<TDataExtra>;

c# generic with slight difference for types?


By : mopman94
Date : March 29 2020, 07:55 AM
I hope this helps you . You can do it if you make an extra Func that performs transformation before calling the var action (which you should rename, because var is a C# keyword).
Here is one approach that you could take:
code :
public static IEnumerator Tweeng<T>(
    this float duration
,   System.Action<T> varAction
,   T aa
,   T zz
) {
    Func<T,T,float,T> transform = MakeTransform<T>();
    float sT = Time.time;
    float eT = sT + duration;
    while (Time.time < eT) {   
        float t = (Time.time-sT)/duration;
        varAction(transform(aa, zz, t));
        yield return null;
    }
    varAction(zz);
}

private static Func<T,T,float,T> MakeTransform<T>() {
    if (typeof(T) == typeof(float)) {
        Func<float, float, float, float> f = Mathf.SmoothStep;
        return (Func<T,T,float,T>)(Delegate)f;
    }
    if (typeof(T) == typeof(Vector3)) {
        Func<Vector3, Vector3, float, Vector3> f = Vector3.Lerp;
        return (Func<T,T,float,T>)(Delegate)f;
    }
    throw new ArgumentException("Unexpected type "+typeof(T));
}
public static IEnumerator DasTweeng<T>( this float duration, System.Action<T> vary, T aa, T zz )
    {
    float sT = Time.time;
    float eT = sT + duration;

    Func<T,T,float,T> step;

    if (typeof(T) == typeof(float))
        step = (Func<T,T,float,T>)(Delegate)(Func<float, float, float, float>)Mathf.SmoothStep;
    else if (typeof(T) == typeof(Vector3))
        step = (Func<T,T,float,T>)(Delegate)(Func<Vector3, Vector3, float, Vector3>)Vector3.Lerp;
    else
        throw new ArgumentException("Unexpected type "+typeof(T));

    while (Time.time < eT)
        {
        float t = (Time.time-sT)/duration;
        vary( step(aa,zz, t) );
        yield return null;
        }
    vary(zz);
    }
    Delegate d;

    if (typeof(T) == typeof(float))
        d = (Func<float, float, float, float>)Mathf.SmoothStep;
    else if (typeof(T) == typeof(Vector3))
        d = (Func<Vector3, Vector3, float, Vector3>)Vector3.Lerp;
    else
        throw new ArgumentException("Unexpected type "+typeof(T));

    Func<T,T,float,T> step = (Func<T,T,float,T>)d;

Slight difference in MYSQL search condition makes huge difference, can't wrap my mind around it


By : maria melanathy
Date : March 29 2020, 07:55 AM
will help you MySQL runs an internal optimizer to determine an execution plan for all queries.
The slight change in the query (in my case) caused the optimizer to come up with a totally different execution plan, hence the huge different in the result for a slight change in one of the values.

Fuzzy matching for slight difference


By : user3292072
Date : March 29 2020, 07:55 AM
it fixes the issue To compare similarity between string, first step is usually cleaning the data with best knowledge you have:
Since many methods for calculating string distance will treat upper-case and lower-case letters as different letters, so first you should convert all characters to the same case. And you could do any other cleaning to help improve the accuracy.
code :
library(dplyr)
companyName <- company$CompanyName %>%
    toupper() %>% # convert to upper case
    stringr::str_replace_all("\\s+"," ") %>% # convert any consecutive whitespaces to single space
    stringr::str_remove_all("\\.|,") # remove all comma or dot
> companyName
[1] "MERCK SHARP & DOHME CORPORATION"          "GILEAD SCIENCES INC"                      "BOEHRINGER INGELHEIM PHARMACEUTICALS INC"
[4] "ABBVIE INC"                               "JANSSEN SCIENTIFIC AFFAIRS LLC"           "BOEHRINGER INGELHEIM PHARMA GMBH & COKG" 
[7] "ASAHI INTECC CO LTD"                      "ASAHI INTECC USA INC"    
distanceMatrix <- stringdist::stringdistmatrix(
    a = companyName,
    b = companyName,
    # You can pick the method that works best for your data. Also, manual inspection is needed. See ?stringdist 
    # I'm picking soundex for this example
    method = "soundex"
)
> distanceMatrix
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    0    1    1    1    1    1    1    1
[2,]    1    0    1    1    1    1    1    1
[3,]    1    1    0    1    1    0    1    1
[4,]    1    1    1    0    1    1    1    1
[5,]    1    1    1    1    0    1    1    1
[6,]    1    1    0    1    1    0    1    1
[7,]    1    1    1    1    1    1    0    0
[8,]    1    1    1    1    1    1    0    0
result <- which(distanceMatrix==0,arr.ind = TRUE) %>%
    as.data.frame() %>%
    dplyr::filter(col > row)
> result
  row col
1   3   6
2   7   8

> result %>% mutate_all(~companyName[.x])
                                       row                                     col
1 BOEHRINGER INGELHEIM PHARMACEUTICALS INC BOEHRINGER INGELHEIM PHARMA GMBH & COKG
2                      ASAHI INTECC CO LTD                    ASAHI INTECC USA INC
> length(companyName) - length(unique(result$row))
[1] 6
Related Posts Related Posts :
  • SQLSERVER - How to list Procs created by a particular user?
  • SSIS Expression to get last day of the month given YYYYMM
  • how to sum up all time values on a given date?
  • Text Clause Explanation
  • SQL Server 2016 - Can't to log into SSMS after install
  • SQL Server table with different case in PowerShell SMO vs SSMS
  • Transpose and Create Variables
  • SQL : Output multiple left joined rows as one record for csv file
  • Removing Date From Date/Time Column
  • Subquery a Cast Function
  • Set based stacking update query
  • Can someone explain the `BypassPrepare` connection-parameter used when building an ETL via SSIS and VS?
  • What is the optimal way to get only latest ID's from table in SQL
  • How to join JSON with table?
  • Transforming a sql table into its inverse
  • Azure SQL Database Pricing
  • Log Reader error while adding a node in SQL Server peer to peer replication
  • Correct way to convert Month Name and Year to complete date SQL Server
  • tsql display value on first row of each group
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org