问:
All com.android.support libraries must use the exact same version specification 28.0.0 vs 26.1.0
I know this was asked here like 100 times before, and I have checked similar questions, but still can't solve it.

In my case, Android Studio says:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0

So I have checked Gradle dependency tree:

```<code>+--- com.android.support.test:runner:1.0.2
|    +--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- com.android.support.test:monitor:1.0.2
|    |    \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- junit:junit:4.12
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    \--- net.sf.kxml:kxml2:2.3.0
+--- com.android.support.test.espresso:espresso-core:3.0.2
|    +--- com.android.support.test:runner:1.0.2 (*)
|    +--- com.android.support.test.espresso:espresso-idling-resource:3.0.2
|    +--- com.squareup:javawriter:2.1.1
|    +--- javax.inject:javax.inject:1
|    +--- org.hamcrest:hamcrest-library:1.3
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- org.hamcrest:hamcrest-integration:1.3
|    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
|    \--- com.google.code.findbugs:jsr305:2.0.1
+--- com.android.support.test:runner:{strictly 1.0.2} -> 1.0.2 (c)
+--- com.android.support:support-annotations:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support.test:monitor:{strictly 1.0.2} -> 1.0.2 (c)
+--- junit:junit:{strictly 4.12} -> 4.12 (c)
+--- org.hamcrest:hamcrest-core:{strictly 1.3} -> 1.3 (c)
+--- net.sf.kxml:kxml2:{strictly 2.3.0} -> 2.3.0 (c)
+--- com.android.support.test.espresso:espresso-core:{strictly 3.0.2} -> 3.0.2 (c)
+--- com.android.support.test.espresso:espresso-idling-resource:{strictly 3.0.2} -> 3.0.2 (c)
+--- com.squareup:javawriter:{strictly 2.1.1} -> 2.1.1 (c)
+--- javax.inject:javax.inject:{strictly 1} -> 1 (c)
+--- org.hamcrest:hamcrest-library:{strictly 1.3} -> 1.3 (c)
+--- org.hamcrest:hamcrest-integration:{strictly 1.3} -> 1.3 (c)
+--- com.google.code.findbugs:jsr305:{strictly 2.0.1} -> 2.0.1 (c)
+--- com.android.support:appcompat-v7:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-compat:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:collections:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.lifecycle:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.core:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.android.support:versionedparcelable:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:cursoradapter:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-core-utils:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:documentfile:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:loader:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.lifecycle:livedata:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.core:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:livedata-core:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:viewmodel:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.android.support:localbroadcastmanager:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:print:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-fragment:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-core-ui:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:customview:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:viewpager:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:coordinatorlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:drawerlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:slidingpanelayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:interpolator:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:swiperefreshlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:asynclayoutinflater:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-vector-drawable:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:animated-vector-drawable:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.persistence.room:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence.room:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence:db-framework:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence:db:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.nostra13.universalimageloader:universal-image-loader:{strictly 1.9.5} -> 1.9.5 (c)
+--- org.jetbrains:annotations-java5:{strictly 15.0} -> 15.0 (c)
+--- pub.devrel:easypermissions:{strictly 2.0.1} -> 2.0.1 (c)
+--- org.locationtech.jts:jts:{strictly 1.16.1} -> 1.16.1 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-navigation:{strictly 0.34.0} -> 0.34.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-services:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-core:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.google.code.gson:gson:{strictly 2.8.5} -> 2.8.5 (c)
+--- com.squareup.retrofit2:retrofit:{strictly 2.4.0} -> 2.4.0 (c)
+--- com.squareup.okhttp3:okhttp:{strictly 3.14.1} -> 3.14.1 (c)
+--- com.squareup.okio:okio:{strictly 1.17.2} -> 1.17.2 (c)
+--- com.squareup.retrofit2:converter-gson:{strictly 2.4.0} -> 2.4.0 (c)
+--- com.squareup.okhttp3:logging-interceptor:{strictly 3.11.0} -> 3.11.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-turf:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-core:{strictly 1.2.0} -> 1.2.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-telemetry:{strictly 4.2.0} -> 4.2.0 (c)
+--- android.arch.lifecycle:extensions:{strictly 1.1.0} -> 1.1.0 (c)
+--- com.mapbox.navigator:mapbox-navigation-native:{strictly 6.1.0} -> 6.1.0 (c)
+--- com.jakewharton.timber:timber:{strictly 4.7.1} -> 4.7.1 (c)
+--- com.google.android.gms:play-services-location:{strictly 16.0.0} -> 16.0.0 (c)
+--- com.google.android.gms:play-services-base:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.google.android.gms:play-services-basement:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.android.support:support-v4:{strictly 26.1.0} -> 26.1.0 (c)
+--- com.android.support:support-media-compat:{strictly 26.1.0} -> 26.1.0 (c)
+--- com.google.android.gms:play-services-tasks:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.google.android.gms:play-services-places-placereport:{strictly 16.0.0} -> 16.0.0 (c)
+--- com.android.support:appcompat-v7:28.0.0
|    +--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-compat:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:collections:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- android.arch.lifecycle:runtime:1.1.1
|    |    |    +--- android.arch.lifecycle:common:1.1.1
|    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    +--- android.arch.core:common:1.1.1
|    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    \--- com.android.support:versionedparcelable:28.0.0
|    |         +--- com.android.support:support-annotations:28.0.0
|    |         \--- com.android.support:collections:28.0.0 (*)
|    +--- com.android.support:collections:28.0.0 (*)
|    +--- com.android.support:cursoradapter:28.0.0
|    |    \--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-core-utils:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:documentfile:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:loader:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- android.arch.lifecycle:livedata:1.1.1
|    |    |    |    +--- android.arch.core:runtime:1.1.1
|    |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1 (*)
|    |    |    |    |    +--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    \--- android.arch.core:runtime:1.1.1 (*)
|    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    \--- android.arch.lifecycle:viewmodel:1.1.1
|    |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    +--- com.android.support:localbroadcastmanager:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    \--- com.android.support:print:28.0.0
|    |         \--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-fragment:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:support-core-ui:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:customview:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:viewpager:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:coordinatorlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:drawerlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:slidingpanelayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:interpolator:28.0.0
|    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:swiperefreshlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:interpolator:28.0.0 (*)
|    |    |    +--- com.android.support:asynclayoutinflater:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    \--- com.android.support:cursoradapter:28.0.0 (*)
|    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:loader:28.0.0 (*)
|    |    \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
|    +--- com.android.support:support-vector-drawable:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    \--- com.android.support:support-compat:28.0.0 (*)
|    \--- com.android.support:animated-vector-drawable:28.0.0
|         +--- com.android.support:support-vector-drawable:28.0.0 (*)
|         \--- com.android.support:support-core-ui:28.0.0 (*)
+--- android.arch.persistence.room:runtime:1.1.1
|    +--- android.arch.persistence.room:common:1.1.1
|    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- android.arch.persistence:db-framework:1.1.1
|    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    \--- android.arch.persistence:db:1.1.1
|    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- android.arch.persistence:db:1.1.1 (*)
|    +--- android.arch.core:runtime:1.1.1 (*)
|    \--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
+--- com.nostra13.universalimageloader:universal-image-loader:1.9.5
+--- org.jetbrains:annotations-java5:15.0
+--- pub.devrel:easypermissions:2.0.1
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    +--- com.android.support:support-compat:28.0.0 (*)
|    \--- com.android.support:support-fragment:28.0.0 (*)
+--- org.locationtech.jts:jts:1.16.1
+--- com.mapbox.mapboxsdk:mapbox-android-navigation:0.34.0
|    +--- com.mapbox.mapboxsdk:mapbox-sdk-services:4.5.0
|    |    +--- com.mapbox.mapboxsdk:mapbox-sdk-core:4.5.0
|    |    |    +--- com.google.code.gson:gson:2.8.5
|    |    |    +--- com.squareup.retrofit2:retrofit:2.4.0
|    |    |    |    \--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.14.1
|    |    |    |         \--- com.squareup.okio:okio:1.17.2
|    |    |    +--- com.squareup.retrofit2:converter-gson:2.4.0
|    |    |    |    +--- com.squareup.retrofit2:retrofit:2.4.0 (*)
|    |    |    |    \--- com.google.code.gson:gson:2.8.2 -> 2.8.5
|    |    |    \--- com.squareup.okhttp3:logging-interceptor:3.11.0
|    |    |         \--- com.squareup.okhttp3:okhttp:3.11.0 -> 3.14.1 (*)
|    |    \--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:4.5.0
|    |         \--- com.google.code.gson:gson:2.8.5
|    +--- com.mapbox.mapboxsdk:mapbox-sdk-turf:4.5.0
|    |    +--- com.mapbox.mapboxsdk:mapbox-sdk-core:4.5.0 (*)
|    |    \--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:4.5.0 (*)
|    +--- com.mapbox.mapboxsdk:mapbox-android-core:1.2.0
|    +--- com.mapbox.mapboxsdk:mapbox-android-telemetry:4.2.0
|    |    +--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.14.1 (*)
|    |    +--- com.google.code.gson:gson:2.8.2 -> 2.8.5
|    |    \--- android.arch.lifecycle:extensions:1.1.0
|    |         +--- android.arch.lifecycle:runtime:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.core:common:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.core:runtime:1.1.0 -> 1.1.1 (*)
|    |         +--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
|    |         +--- android.arch.lifecycle:common:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.lifecycle:livedata:1.1.0 -> 1.1.1 (*)
|    |         \--- android.arch.lifecycle:viewmodel:1.1.0 -> 1.1.1 (*)
|    +--- com.mapbox.navigator:mapbox-navigation-native:6.1.0
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    \--- com.jakewharton.timber:timber:4.7.1
+--- com.squareup.okhttp3:okhttp:3.14.1 (*)
\--- com.google.android.gms:play-services-location:16.0.0
    +--- com.google.android.gms:play-services-base:16.0.1
    |    +--- com.google.android.gms:play-services-basement:16.0.1
    |    |    \--- com.android.support:support-v4:26.1.0
    |    |         +--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-media-compat:26.1.0
    |    |         |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
    |    |         |    \--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-ui:26.1.0 -> 28.0.0 (*)
    |    |         \--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
    |    \--- com.google.android.gms:play-services-tasks:16.0.1
    |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-places-placereport:16.0.0
    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
</code>```

I am quite confused from this output. It seems that for example com.android.support.test:runner:1.0.2 needs com.android.support:support-v4:{strictly 26.1.0}, but I couldn't find any newer version than 1.0.2 of mentioned library. Also at same time is needs com.android.support:appcompat-v7:{strictly 28.0.0}. So it basically needs the same library in two versions?? I am really not sure what to think about this, let alone to fix it. Please help :D

Here is my build.gradle:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.sanctusmedia.android.WattsUp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "0.07"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains:annotations-java5:15.0'

    // Room persistence library (https://developer.android.com/training/data-storage/room/index.html#java)
    implementation "android.arch.persistence.room:runtime:1.1.1"
    annotationProcessor "android.arch.persistence.room:compiler:1.1.1"

    // https://github.com/nostra13/Android-Universal-Image-Loader, Apache 2.0 license
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

    // Easy permissions: https://github.com/googlesamples/easypermissions, Apache 2.0 license
    implementation 'pub.devrel:easypermissions:2.0.1'

    // JTS Topology Suite - predecessor of GEOS: https://github.com/locationtech/jts, EDL v1.0 license
    implementation group: 'org.locationtech.jts', name: 'jts', version: '1.16.1', ext: 'pom'

    // MapBox, see: https://www.mapbox.com
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.34.0'

    // OkHTTP, see: https://github.com/square/okhttp, Apache 2.0 license
    implementation("com.squareup.okhttp3:okhttp:3.14.1")

    // Google Play services for faster GPS lock
    implementation 'com.google.android.gms:play-services-location:16.0.0'
}

configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
}
</code>```

答:
It's an alternative solution to override during dependency resolution. You can put the follow snippet in root level build.gradle:

```<code>buildscript {
    // ...
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "28.0.0"
                }
            }
        }
    }
}
</code>```

Body:
I know this was asked here like 100 times before, and I have checked similar questions, but still can't solve it.

In my case, Android Studio says:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0

So I have checked Gradle dependency tree:

+--- com.android.support.test:runner:1.0.2
|    +--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- com.android.support.test:monitor:1.0.2
|    |    \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- junit:junit:4.12
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    \--- net.sf.kxml:kxml2:2.3.0
+--- com.android.support.test.espresso:espresso-core:3.0.2
|    +--- com.android.support.test:runner:1.0.2 (*)
|    +--- com.android.support.test.espresso:espresso-idling-resource:3.0.2
|    +--- com.squareup:javawriter:2.1.1
|    +--- javax.inject:javax.inject:1
|    +--- org.hamcrest:hamcrest-library:1.3
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- org.hamcrest:hamcrest-integration:1.3
|    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
|    \--- com.google.code.findbugs:jsr305:2.0.1
+--- com.android.support.test:runner:{strictly 1.0.2} -> 1.0.2 (c)
+--- com.android.support:support-annotations:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support.test:monitor:{strictly 1.0.2} -> 1.0.2 (c)
+--- junit:junit:{strictly 4.12} -> 4.12 (c)
+--- org.hamcrest:hamcrest-core:{strictly 1.3} -> 1.3 (c)
+--- net.sf.kxml:kxml2:{strictly 2.3.0} -> 2.3.0 (c)
+--- com.android.support.test.espresso:espresso-core:{strictly 3.0.2} -> 3.0.2 (c)
+--- com.android.support.test.espresso:espresso-idling-resource:{strictly 3.0.2} -> 3.0.2 (c)
+--- com.squareup:javawriter:{strictly 2.1.1} -> 2.1.1 (c)
+--- javax.inject:javax.inject:{strictly 1} -> 1 (c)
+--- org.hamcrest:hamcrest-library:{strictly 1.3} -> 1.3 (c)
+--- org.hamcrest:hamcrest-integration:{strictly 1.3} -> 1.3 (c)
+--- com.google.code.findbugs:jsr305:{strictly 2.0.1} -> 2.0.1 (c)
+--- com.android.support:appcompat-v7:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-compat:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:collections:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.lifecycle:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.core:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.android.support:versionedparcelable:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:cursoradapter:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-core-utils:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:documentfile:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:loader:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.lifecycle:livedata:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.core:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:livedata-core:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:viewmodel:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.android.support:localbroadcastmanager:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:print:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-fragment:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-core-ui:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:customview:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:viewpager:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:coordinatorlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:drawerlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:slidingpanelayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:interpolator:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:swiperefreshlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:asynclayoutinflater:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-vector-drawable:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:animated-vector-drawable:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.persistence.room:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence.room:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence:db-framework:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence:db:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.nostra13.universalimageloader:universal-image-loader:{strictly 1.9.5} -> 1.9.5 (c)
+--- org.jetbrains:annotations-java5:{strictly 15.0} -> 15.0 (c)
+--- pub.devrel:easypermissions:{strictly 2.0.1} -> 2.0.1 (c)
+--- org.locationtech.jts:jts:{strictly 1.16.1} -> 1.16.1 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-navigation:{strictly 0.34.0} -> 0.34.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-services:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-core:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.google.code.gson:gson:{strictly 2.8.5} -> 2.8.5 (c)
+--- com.squareup.retrofit2:retrofit:{strictly 2.4.0} -> 2.4.0 (c)
+--- com.squareup.okhttp3:okhttp:{strictly 3.14.1} -> 3.14.1 (c)
+--- com.squareup.okio:okio:{strictly 1.17.2} -> 1.17.2 (c)
+--- com.squareup.retrofit2:converter-gson:{strictly 2.4.0} -> 2.4.0 (c)
+--- com.squareup.okhttp3:logging-interceptor:{strictly 3.11.0} -> 3.11.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-turf:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-core:{strictly 1.2.0} -> 1.2.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-telemetry:{strictly 4.2.0} -> 4.2.0 (c)
+--- android.arch.lifecycle:extensions:{strictly 1.1.0} -> 1.1.0 (c)
+--- com.mapbox.navigator:mapbox-navigation-native:{strictly 6.1.0} -> 6.1.0 (c)
+--- com.jakewharton.timber:timber:{strictly 4.7.1} -> 4.7.1 (c)
+--- com.google.android.gms:play-services-location:{strictly 16.0.0} -> 16.0.0 (c)
+--- com.google.android.gms:play-services-base:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.google.android.gms:play-services-basement:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.android.support:support-v4:{strictly 26.1.0} -> 26.1.0 (c)
+--- com.android.support:support-media-compat:{strictly 26.1.0} -> 26.1.0 (c)
+--- com.google.android.gms:play-services-tasks:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.google.android.gms:play-services-places-placereport:{strictly 16.0.0} -> 16.0.0 (c)
+--- com.android.support:appcompat-v7:28.0.0
|    +--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-compat:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:collections:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- android.arch.lifecycle:runtime:1.1.1
|    |    |    +--- android.arch.lifecycle:common:1.1.1
|    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    +--- android.arch.core:common:1.1.1
|    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    \--- com.android.support:versionedparcelable:28.0.0
|    |         +--- com.android.support:support-annotations:28.0.0
|    |         \--- com.android.support:collections:28.0.0 (*)
|    +--- com.android.support:collections:28.0.0 (*)
|    +--- com.android.support:cursoradapter:28.0.0
|    |    \--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-core-utils:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:documentfile:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:loader:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- android.arch.lifecycle:livedata:1.1.1
|    |    |    |    +--- android.arch.core:runtime:1.1.1
|    |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1 (*)
|    |    |    |    |    +--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    \--- android.arch.core:runtime:1.1.1 (*)
|    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    \--- android.arch.lifecycle:viewmodel:1.1.1
|    |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    +--- com.android.support:localbroadcastmanager:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    \--- com.android.support:print:28.0.0
|    |         \--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-fragment:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:support-core-ui:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:customview:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:viewpager:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:coordinatorlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:drawerlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:slidingpanelayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:interpolator:28.0.0
|    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:swiperefreshlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:interpolator:28.0.0 (*)
|    |    |    +--- com.android.support:asynclayoutinflater:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    \--- com.android.support:cursoradapter:28.0.0 (*)
|    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:loader:28.0.0 (*)
|    |    \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
|    +--- com.android.support:support-vector-drawable:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    \--- com.android.support:support-compat:28.0.0 (*)
|    \--- com.android.support:animated-vector-drawable:28.0.0
|         +--- com.android.support:support-vector-drawable:28.0.0 (*)
|         \--- com.android.support:support-core-ui:28.0.0 (*)
+--- android.arch.persistence.room:runtime:1.1.1
|    +--- android.arch.persistence.room:common:1.1.1
|    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- android.arch.persistence:db-framework:1.1.1
|    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    \--- android.arch.persistence:db:1.1.1
|    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- android.arch.persistence:db:1.1.1 (*)
|    +--- android.arch.core:runtime:1.1.1 (*)
|    \--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
+--- com.nostra13.universalimageloader:universal-image-loader:1.9.5
+--- org.jetbrains:annotations-java5:15.0
+--- pub.devrel:easypermissions:2.0.1
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    +--- com.android.support:support-compat:28.0.0 (*)
|    \--- com.android.support:support-fragment:28.0.0 (*)
+--- org.locationtech.jts:jts:1.16.1
+--- com.mapbox.mapboxsdk:mapbox-android-navigation:0.34.0
|    +--- com.mapbox.mapboxsdk:mapbox-sdk-services:4.5.0
|    |    +--- com.mapbox.mapboxsdk:mapbox-sdk-core:4.5.0
|    |    |    +--- com.google.code.gson:gson:2.8.5
|    |    |    +--- com.squareup.retrofit2:retrofit:2.4.0
|    |    |    |    \--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.14.1
|    |    |    |         \--- com.squareup.okio:okio:1.17.2
|    |    |    +--- com.squareup.retrofit2:converter-gson:2.4.0
|    |    |    |    +--- com.squareup.retrofit2:retrofit:2.4.0 (*)
|    |    |    |    \--- com.google.code.gson:gson:2.8.2 -> 2.8.5
|    |    |    \--- com.squareup.okhttp3:logging-interceptor:3.11.0
|    |    |         \--- com.squareup.okhttp3:okhttp:3.11.0 -> 3.14.1 (*)
|    |    \--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:4.5.0
|    |         \--- com.google.code.gson:gson:2.8.5
|    +--- com.mapbox.mapboxsdk:mapbox-sdk-turf:4.5.0
|    |    +--- com.mapbox.mapboxsdk:mapbox-sdk-core:4.5.0 (*)
|    |    \--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:4.5.0 (*)
|    +--- com.mapbox.mapboxsdk:mapbox-android-core:1.2.0
|    +--- com.mapbox.mapboxsdk:mapbox-android-telemetry:4.2.0
|    |    +--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.14.1 (*)
|    |    +--- com.google.code.gson:gson:2.8.2 -> 2.8.5
|    |    \--- android.arch.lifecycle:extensions:1.1.0
|    |         +--- android.arch.lifecycle:runtime:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.core:common:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.core:runtime:1.1.0 -> 1.1.1 (*)
|    |         +--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
|    |         +--- android.arch.lifecycle:common:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.lifecycle:livedata:1.1.0 -> 1.1.1 (*)
|    |         \--- android.arch.lifecycle:viewmodel:1.1.0 -> 1.1.1 (*)
|    +--- com.mapbox.navigator:mapbox-navigation-native:6.1.0
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    \--- com.jakewharton.timber:timber:4.7.1
+--- com.squareup.okhttp3:okhttp:3.14.1 (*)
\--- com.google.android.gms:play-services-location:16.0.0
    +--- com.google.android.gms:play-services-base:16.0.1
    |    +--- com.google.android.gms:play-services-basement:16.0.1
    |    |    \--- com.android.support:support-v4:26.1.0
    |    |         +--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-media-compat:26.1.0
    |    |         |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
    |    |         |    \--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-ui:26.1.0 -> 28.0.0 (*)
    |    |         \--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
    |    \--- com.google.android.gms:play-services-tasks:16.0.1
    |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-places-placereport:16.0.0
    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)

I am quite confused from this output. It seems that for example com.android.support.test:runner:1.0.2 needs com.android.support:support-v4:{strictly 26.1.0}, but I couldn't find any newer version than 1.0.2 of mentioned library. Also at same time is needs com.android.support:appcompat-v7:{strictly 28.0.0}. So it basically needs the same library in two versions?? I am really not sure what to think about this, let alone to fix it. Please help :D

Here is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.sanctusmedia.android.WattsUp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "0.07"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains:annotations-java5:15.0'

    // Room persistence library (https://developer.android.com/training/data-storage/room/index.html#java)
    implementation "android.arch.persistence.room:runtime:1.1.1"
    annotationProcessor "android.arch.persistence.room:compiler:1.1.1"

    // https://github.com/nostra13/Android-Universal-Image-Loader, Apache 2.0 license
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

    // Easy permissions: https://github.com/googlesamples/easypermissions, Apache 2.0 license
    implementation 'pub.devrel:easypermissions:2.0.1'

    // JTS Topology Suite - predecessor of GEOS: https://github.com/locationtech/jts, EDL v1.0 license
    implementation group: 'org.locationtech.jts', name: 'jts', version: '1.16.1', ext: 'pom'

    // MapBox, see: https://www.mapbox.com
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.34.0'

    // OkHTTP, see: https://github.com/square/okhttp, Apache 2.0 license
    implementation("com.squareup.okhttp3:okhttp:3.14.1")

    // Google Play services for faster GPS lock
    implementation 'com.google.android.gms:play-services-location:16.0.0'
}

configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
}

Body:
It's an alternative solution to override during dependency resolution. You can put the follow snippet in root level build.gradle:

buildscript {
    // ...
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "28.0.0"
                }
            }
        }
    }
}


来源: stackexchange

问:
Checking if a collection is null or empty in Groovy
I need to perform a null or empty check on a collection; I think that !members?.empty is incorrect.  Is there a groovier way to write the following?

```<code>if (members && !members.empty) {
    // Some Work
}
</code>```

答:
```<code>!members.find()
</code>```

I think now the best way to solve this issue is code above. It works since Groovy 1.8.1 http://docs.groovy-lang.org/docs/next/html/groovy-jdk/java/util/Collection.html#find(). Examples:

```<code>def lst1 = []
assert !lst1.find()

def lst2 = [null]
assert !lst2.find()

def lst3 = [null,2,null]
assert lst3.find()

def lst4 = [null,null,null]
assert !lst4.find()

def lst5 = [null, 0, 0.0, false, '', [], 42, 43]
assert lst5.find() == 42

def lst6 = null;
assert !lst6.find()
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I need to perform a null or empty check on a collection; I think that !members?.empty is incorrect.  Is there a groovier way to write the following?

if (members && !members.empty) {
    // Some Work
}

Body:
!members.find()

I think now the best way to solve this issue is code above. It works since Groovy 1.8.1 http://docs.groovy-lang.org/docs/next/html/groovy-jdk/java/util/Collection.html#find(). Examples:

def lst1 = []
assert !lst1.find()

def lst2 = [null]
assert !lst2.find()

def lst3 = [null,2,null]
assert lst3.find()

def lst4 = [null,null,null]
assert !lst4.find()

def lst5 = [null, 0, 0.0, false, '', [], 42, 43]
assert lst5.find() == 42

def lst6 = null;
assert !lst6.find()


问:
Vlookup without repetition using vba on excel
I am trying to put in place a macro that allows me to match identical entry from one table to another. The tricky part is that if a match is found, it cannot be repeated. The way I theorized it is kind of elementary, however it is the only way I can think of it given my still limited knowledge in VBA.

The structure

Both tables need to be first filtered in order to allow the non-repetition condition.

Store the searching values as arrays in order to speed up the process of the macro

Match the entries to search with the ones from the targeted table in order to find matches. This is done with the in-application function MATCH. The MATCH function returns the cell where the match is situated, this is useful as it constantly shift the range in order to not repeate the same value all the time.

After calculating the shifting range, I use a VLookup function in order to return the second entry.

Unfortunately, the macro is incomplete. I cannot find a way to constantly shift the range without compromising the mechanism. The problem resides in the shifting range that is not created correctly to shift after each match.

Desired result

In the below image the desired result would be to check if all items in the left table are in the right table. Take item A, I need to find two item As. I have in the right column a first item A with value 17 and a second item A with value 81. If I do not find any value I have nothing, as it is the case of Ds and E. If instead I have less entries in the left table (as it is for the case of entry L) then I need to return all values of Entry L: 96; 77; 40.

```<code>    Sub Matching11()
ThisWorkbook.Activate

Worksheets.add

Worksheets("Test4").Range("A1:T110").copy Destination:=ActiveSheet.Range("A1")

With ActiveSheet

    Dim Search_Array As Variant
    Search_Array = Range("C2", Range("C1").End(xlDown)) 'use this array to loop through the value to search for

    Dim Target_MatchValue As Integer
    Dim Target_Range As Range
    Dim arr As Variant
    Dim counter As Integer
    Dim n As Integer

    counter = 0
    n = 0
    Target_MatchValue = 0

    For counter = LBound(Search_Array) To UBound(Search_Array)
        Target_MatchValue = 0

        Target_MatchValue = Application.Match(Search_Array(counter, 1), .Range("H2:H200"), 0) - 1 'change C column with the range where you will have the tyres you need search for
        Set Target_Range = .Range(.Cells(2 + n, 8), .Cells(1000, 9))  'this is supposed to work as a shifting range allowing to match entries without making repetitions. I used the MATCH function in order to set the start of the range. i.e. if there is a match in the target table the range will shift from the location of the match downwards. If the match is at on the same level then it does not shift the range in order to match the same-level entry afterwards it is supposed to shift by one unit in order to prevent repetitions.
        'If arr = Application.VLookup(Search_Array(counter, 1), Target_Range, 2, False) Is Nothing Then GoTo NextCounter    'I used Vlookup in order to return the value set in the second column of the targetted table. As alternative, I think I could just use offset since I previously used MQTCH

        arr = Application.VLookup(Search_Array(counter, 1), Target_Range, 2, False)
        If IsError(arr) Then
            GoTo NextCounter
            Else
            .Range(Cells(1 + counter, 6), Cells(1 + counter, 6)).value = arr 'Return the value of the array in this cell
        End If
        Target_Range.Select

        If Target_MatchValue = 0 Then

            n = n + 1

            ElseIf Target_MatchValue > 0 Then
            n = n + Target_MatchValue
        End If
        .Range(Cells(1 + counter, 5), Cells(1 + counter, 5)).value = Search_Array(counter, 1) 'Return the value of the array in this cell
    Next counter

NextCounter:
Next counter

End With

End Sub
</code>```

答:
Apologies for the unclear explanation of the problem. I have provided here below a solution I have sorted out. I was looking for a code that could execute vlookup without returning the same values. Below is the solution. I am aware that the code might not be the cleanest and most elegant one but it is effective and run fast enough for large data sample.

```<code>Sub Matching()

    Dim Search_Array As Variant
    Dim Target_MatchValue As Variant
    Dim Target_Range As Range
    Dim arr As Variant
    Dim counter As Integer
    Dim n As Integer

    'data must be ordered in order to apply the non-repetitive condition
    Search_Array = Sheet1.Range("A2", Sheet1.Range("A1").End(xlDown)) 'use this array to loop through the value to search for

    n = 0
    Sheet1.Activate
    With ActiveSheet
        For counter = LBound(Search_Array) To UBound(Search_Array)

            Target_MatchValue = 0
            Target_MatchValue = Application.Match(Search_Array(counter, 1), .Range(Cells(2 + n, 4), Cells(1000, 4)), 0) 'This code will return the value used for the shifting range
            Set Target_Range = .Range(Cells(2 + n, 4), Cells(1000, 5))  'this is supposed to work as a shifting range allowing to match entries without making repetitions. I used the MATCH function in order to set the start of the range. i.e. if there is a match in the target table the range will shift from the location of the match downwards. If the match is at on the same level then it does not shift the range in order to match the same-level entry afterwards it is supposed to shift by one unit in order to prevent repetitions.
            'target_range.select Activate this code in order to see the macro in action
            arr = Application.VLookup(Search_Array(counter, 1), Target_Range, 2, False) 'store the vlookup value in an array in order to increase the efficiency the code and to speed up the whole proces

                If IsError(arr) Then
                    .Cells(2 + n, 2).value = "" 'if the macro does not find anything, no value will be recorded anywhere

                    Else
                    .Cells(1 + n + Target_MatchValue, 2).value = Search_Array(counter, 2)  'Return the value of the search_array in this cell so to match column A values with column D values if they are found

                End If

                If IsError(arr) Then
                        n = n
                    ElseIf Target_MatchValue = 0 Then 'if the macro does not find anything, the shifting range does not shift so that subsequent values can be searched in the same range without missing precious matches
                        n = n + 1

                    ElseIf Target_MatchValue > 0 Then 'if there is a matching value between Column A and Column B, the shifting range shifts by the n + the distance between the the current vlookupvalue and the found value. Note that Data must be stored in a filtered order otherwise vlookup will not work correctly
                        n = n + Target_MatchValue

                End If
        Next counter

    End With

End Sub
</code>```

By exchanging ideas with some friends, I was told to think about a potential helper column that would be used to store incremental numbers. This helper column would store incremental numbers that would help to meet the non-repetition condition. Please see the below example.

The idea here is that if a value is found in column E, I store n being equal to the value found in the helper column. Then the code needs to verify if the future values' n are bigger than previous n. If this condition is met, then the one-repetition condition is fulfilled. n changes value to the next bigger value.
For example, if I find L in the right table, I report 96 as value and store N being equal to 11. When I search for the next value of L, the new n must be bigger than the current n otherwise I will not store the new found value. The value 77 found has indeed a bigger n than the previous value as 12 is bigger than 11. I hope this helps.

Body:
I am trying to put in place a macro that allows me to match identical entry from one table to another. The tricky part is that if a match is found, it cannot be repeated. The way I theorized it is kind of elementary, however it is the only way I can think of it given my still limited knowledge in VBA.

The structure

Both tables need to be first filtered in order to allow the non-repetition condition.

Store the searching values as arrays in order to speed up the process of the macro

Match the entries to search with the ones from the targeted table in order to find matches. This is done with the in-application function MATCH. The MATCH function returns the cell where the match is situated, this is useful as it constantly shift the range in order to not repeate the same value all the time.

After calculating the shifting range, I use a VLookup function in order to return the second entry.

Unfortunately, the macro is incomplete. I cannot find a way to constantly shift the range without compromising the mechanism. The problem resides in the shifting range that is not created correctly to shift after each match.

Desired result

In the below image the desired result would be to check if all items in the left table are in the right table. Take item A, I need to find two item As. I have in the right column a first item A with value 17 and a second item A with value 81. If I do not find any value I have nothing, as it is the case of Ds and E. If instead I have less entries in the left table (as it is for the case of entry L) then I need to return all values of Entry L: 96; 77; 40.

    Sub Matching11()
ThisWorkbook.Activate

Worksheets.add

Worksheets("Test4").Range("A1:T110").copy Destination:=ActiveSheet.Range("A1")

With ActiveSheet

    Dim Search_Array As Variant
    Search_Array = Range("C2", Range("C1").End(xlDown)) 'use this array to loop through the value to search for

    Dim Target_MatchValue As Integer
    Dim Target_Range As Range
    Dim arr As Variant
    Dim counter As Integer
    Dim n As Integer

    counter = 0
    n = 0
    Target_MatchValue = 0

    For counter = LBound(Search_Array) To UBound(Search_Array)
        Target_MatchValue = 0

        Target_MatchValue = Application.Match(Search_Array(counter, 1), .Range("H2:H200"), 0) - 1 'change C column with the range where you will have the tyres you need search for
        Set Target_Range = .Range(.Cells(2 + n, 8), .Cells(1000, 9))  'this is supposed to work as a shifting range allowing to match entries without making repetitions. I used the MATCH function in order to set the start of the range. i.e. if there is a match in the target table the range will shift from the location of the match downwards. If the match is at on the same level then it does not shift the range in order to match the same-level entry afterwards it is supposed to shift by one unit in order to prevent repetitions.
        'If arr = Application.VLookup(Search_Array(counter, 1), Target_Range, 2, False) Is Nothing Then GoTo NextCounter    'I used Vlookup in order to return the value set in the second column of the targetted table. As alternative, I think I could just use offset since I previously used MQTCH

        arr = Application.VLookup(Search_Array(counter, 1), Target_Range, 2, False)
        If IsError(arr) Then
            GoTo NextCounter
            Else
            .Range(Cells(1 + counter, 6), Cells(1 + counter, 6)).value = arr 'Return the value of the array in this cell
        End If
        Target_Range.Select

        If Target_MatchValue = 0 Then

            n = n + 1

            ElseIf Target_MatchValue > 0 Then
            n = n + Target_MatchValue
        End If
        .Range(Cells(1 + counter, 5), Cells(1 + counter, 5)).value = Search_Array(counter, 1) 'Return the value of the array in this cell
    Next counter

NextCounter:
Next counter

End With

End Sub

Body:
Apologies for the unclear explanation of the problem. I have provided here below a solution I have sorted out. I was looking for a code that could execute vlookup without returning the same values. Below is the solution. I am aware that the code might not be the cleanest and most elegant one but it is effective and run fast enough for large data sample.

Sub Matching()

    Dim Search_Array As Variant
    Dim Target_MatchValue As Variant
    Dim Target_Range As Range
    Dim arr As Variant
    Dim counter As Integer
    Dim n As Integer

    'data must be ordered in order to apply the non-repetitive condition
    Search_Array = Sheet1.Range("A2", Sheet1.Range("A1").End(xlDown)) 'use this array to loop through the value to search for

    n = 0
    Sheet1.Activate
    With ActiveSheet
        For counter = LBound(Search_Array) To UBound(Search_Array)

            Target_MatchValue = 0
            Target_MatchValue = Application.Match(Search_Array(counter, 1), .Range(Cells(2 + n, 4), Cells(1000, 4)), 0) 'This code will return the value used for the shifting range
            Set Target_Range = .Range(Cells(2 + n, 4), Cells(1000, 5))  'this is supposed to work as a shifting range allowing to match entries without making repetitions. I used the MATCH function in order to set the start of the range. i.e. if there is a match in the target table the range will shift from the location of the match downwards. If the match is at on the same level then it does not shift the range in order to match the same-level entry afterwards it is supposed to shift by one unit in order to prevent repetitions.
            'target_range.select Activate this code in order to see the macro in action
            arr = Application.VLookup(Search_Array(counter, 1), Target_Range, 2, False) 'store the vlookup value in an array in order to increase the efficiency the code and to speed up the whole proces

                If IsError(arr) Then
                    .Cells(2 + n, 2).value = "" 'if the macro does not find anything, no value will be recorded anywhere

                    Else
                    .Cells(1 + n + Target_MatchValue, 2).value = Search_Array(counter, 2)  'Return the value of the search_array in this cell so to match column A values with column D values if they are found

                End If

                If IsError(arr) Then
                        n = n
                    ElseIf Target_MatchValue = 0 Then 'if the macro does not find anything, the shifting range does not shift so that subsequent values can be searched in the same range without missing precious matches
                        n = n + 1

                    ElseIf Target_MatchValue > 0 Then 'if there is a matching value between Column A and Column B, the shifting range shifts by the n + the distance between the the current vlookupvalue and the found value. Note that Data must be stored in a filtered order otherwise vlookup will not work correctly
                        n = n + Target_MatchValue

                End If
        Next counter

    End With

End Sub

By exchanging ideas with some friends, I was told to think about a potential helper column that would be used to store incremental numbers. This helper column would store incremental numbers that would help to meet the non-repetition condition. Please see the below example.

The idea here is that if a value is found in column E, I store n being equal to the value found in the helper column. Then the code needs to verify if the future values' n are bigger than previous n. If this condition is met, then the one-repetition condition is fulfilled. n changes value to the next bigger value.
For example, if I find L in the right table, I report 96 as value and store N being equal to 11. When I search for the next value of L, the new n must be bigger than the current n otherwise I will not store the new found value. The value 77 found has indeed a bigger n than the previous value as 12 is bigger than 11. I hope this helps.


问:
Calculate mean of specific row pattern
I have a dataframe like this:

```<code>V1 = paste0("AB", seq(1:48))
V2 = seq(1:48)

test = data.frame(name = V1, value = V2)
</code>```

I want to calculate the means of the value-column and specific rows.

The pattern of the rows is pretty complicated:

```<code>Rows of MeanA1: 1, 5, 9
Rows of MeanA2: 2, 6, 10
Rows of MeanA3: 3, 7, 11
Rows of MeanA4: 4, 8, 12

Rows of MeanB1: 13, 17, 21
Rows of MeanB2: 14, 18, 22
Rows of MeanB3: 15, 19, 23
Rows of MeanB4: 16, 20, 24

Rows of MeanC1: 25, 29, 33
Rows of MeanC2: 26, 30, 34
Rows of MeanC3: 27, 31, 35
Rows of MeanC4: 28, 32, 36

Rows of MeanD1: 37, 41, 45
Rows of MeanD2: 38, 42, 46
Rows of MeanD3: 39, 43, 47
Rows of MeanD4: 40, 44, 48
</code>```

As you see its starting at 4 different points (1, 13, 25, 37) then always +4 and for the following 4 means its just stepping 1 more row down.

I would like to have an output of all these means in one list.

Any ideas? NOTE: In this example the mean is of course always the middle number, but my real df is different.

答:
Not quite sure about the output format you require, but the following codes can calculate what you want anyhow.</p>

```<code>calc_mean1 <- function(x) mean(test$value[seq(x, by = 4, length.out = 3)])
calc_mean2 <- function(x){sapply(x:(x+3), calc_mean1)}
output <- lapply(seq(1, 37, 12), calc_mean2)
names(output) <- paste0('Mean', LETTERS[seq_along(output)]) # remove this line if more than 26 groups.
output

## $MeanA
## [1] 5 6 7 8

## $MeanB
## [1] 17 18 19 20

## $MeanC
## [1] 29 30 31 32

## $MeanD
## [1] 41 42 43 44
</code>```

Title: Calculate mean of specific row pattern

Body:
I have a dataframe like this:

V1 = paste0("AB", seq(1:48))
V2 = seq(1:48)

test = data.frame(name = V1, value = V2)

I want to calculate the means of the value-column and specific rows.

The pattern of the rows is pretty complicated:

Rows of MeanA1: 1, 5, 9
Rows of MeanA2: 2, 6, 10
Rows of MeanA3: 3, 7, 11
Rows of MeanA4: 4, 8, 12

Rows of MeanB1: 13, 17, 21
Rows of MeanB2: 14, 18, 22
Rows of MeanB3: 15, 19, 23
Rows of MeanB4: 16, 20, 24

Rows of MeanC1: 25, 29, 33
Rows of MeanC2: 26, 30, 34
Rows of MeanC3: 27, 31, 35
Rows of MeanC4: 28, 32, 36

Rows of MeanD1: 37, 41, 45
Rows of MeanD2: 38, 42, 46
Rows of MeanD3: 39, 43, 47
Rows of MeanD4: 40, 44, 48

As you see its starting at 4 different points (1, 13, 25, 37) then always +4 and for the following 4 means its just stepping 1 more row down.

I would like to have an output of all these means in one list.

Any ideas? NOTE: In this example the mean is of course always the middle number, but my real df is different.

Body:
Not quite sure about the output format you require, but the following codes can calculate what you want anyhow.

calc_mean1 <- function(x) mean(test$value[seq(x, by = 4, length.out = 3)])
calc_mean2 <- function(x){sapply(x:(x+3), calc_mean1)}
output <- lapply(seq(1, 37, 12), calc_mean2)
names(output) <- paste0('Mean', LETTERS[seq_along(output)]) # remove this line if more than 26 groups.
output

## $MeanA
## [1] 5 6 7 8

## $MeanB
## [1] 17 18 19 20

## $MeanC
## [1] 29 30 31 32

## $MeanD
## [1] 41 42 43 44


问:
Sporadic error downloading data from PHP application
A PHP application is offering binary data as a download:

```<code>header("Content-Type: application/octet-stream");
header("Pragma: public");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("expires: 0");
set_time_limit(0);
ob_clean();
flush();
@readfile($completefilename); exit;
</code>```

$completefilename is a stream like "ftp://user:pwd@..."

The size of the data can be several MByte. It works fine, but sporadically I get the following error:

答:
Do you have anything in your error logs?
Maybe PHP is running out of memory because readfile() needs to pull the while file into memory. Make sure memory_limit is larger than the largest file  you work on with readfile(). Another option is to output the file in chunks using fread().</p>

ContentLicense: CC BY-SA 3.0

Body:
A PHP application is offering binary data as a download:

header("Content-Type: application/octet-stream");
header("Pragma: public");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("expires: 0");
set_time_limit(0);
ob_clean();
flush();
@readfile($completefilename); exit;

$completefilename is a stream like "ftp://user:pwd@..."

The size of the data can be several MByte. It works fine, but sporadically I get the following error:


问:
Safari background-color transition to transparent when fixed. Bug?
I have a problem transitioning background-color to transparent in Safari 12.1 (14607.1.40.1.4).

The code will not transition the background to transparent. Instead it flickers or does nothing att all when hovered.

The transitions seems to work fine in Chrome and Firefox. And it does work in Safari aswell if

The div is empty

OR Position:fixed is removed

OR The target background-color is set to a color (rgba transparency doesnt work though)

```<code><!DOCTYPE html>
<html>
    <head>
        <style>
        body{
            background-color:white;
        }
        .box{
            width:200px;
            height:100px;
            background-color:lightblue;
            transition:1s all;
            position:fixed;
        }
        .box:hover{
            background-color:transparent;
        }
        </style>
    </head>
    <body>
        <div class="box">test</div>
    </body>
</html>
</code>```

I want to be able to transition a fixed divs background-color to transparent. Is there a way to get this to work?

答:
I just hit the same Safari bug and was very frustrated with it...

It seems that position: fixed and background: transparent don't work well together on Safari.

I ended up adding a div inside my "fixed" div and used that for my background color transition.

Body:
I have a problem transitioning background-color to transparent in Safari 12.1 (14607.1.40.1.4).

The code will not transition the background to transparent. Instead it flickers or does nothing att all when hovered.

The transitions seems to work fine in Chrome and Firefox. And it does work in Safari aswell if

The div is empty

OR Position:fixed is removed

OR The target background-color is set to a color (rgba transparency doesnt work though)

<!DOCTYPE html>

test

I want to be able to transition a fixed divs background-color to transparent. Is there a way to get this to work?


答:
An idea via base R is to create a grouping variable for every 4 rows, split the data every 12 rows (nrow(test) / 4) and aggregate to find the mean, i.e.

```<code>test$new = rep(1:4, nrow(test)%/%4)
lapply(split(test, rep(1:4, each = nrow(test) %/% 4)), function(i)
                                              aggregate(value ~ new, i, mean))

#    $`1`
#      new value
#    1   1     5
#    2   2     6
#    3   3     7
#    4   4     8

#    $`2`
#      new value
#    1   1    17
#    2   2    18
#    3   3    19
#    4   4    20

#    $`3`
#      new value
#    1   1    29
#    2   2    30
#    3   3    31
#    4   4    32

#    $`4`
#      new value
#    1   1    41
#    2   2    42
#    3   3    43
#    4   4    44
</code>```

Title: Calculate mean of specific row pattern

Body:
An idea via base R is to create a grouping variable for every 4 rows, split the data every 12 rows (nrow(test) / 4) and aggregate to find the mean, i.e.

test$new = rep(1:4, nrow(test)%/%4)
lapply(split(test, rep(1:4, each = nrow(test) %/% 4)), function(i)
                                              aggregate(value ~ new, i, mean))

#    $`1`
#      new value
#    1   1     5
#    2   2     6
#    3   3     7
#    4   4     8

#    $`2`
#      new value
#    1   1    17
#    2   2    18
#    3   3    19
#    4   4    20

#    $`3`
#      new value
#    1   1    29
#    2   2    30
#    3   3    31
#    4   4    32

#    $`4`
#      new value
#    1   1    41
#    2   2    42
#    3   3    43
#    4   4    44


问:
How to call a command from window pop in wpf
How call a delegate command from window pop up.
I'm showing a pop up window over a window..
The pop up window have button which need to call DelegateCommand from ViewModel.

Below is the code for Window > MyPopUp.xaml.cs

```<code>public partial class MyPopUp : Window
{
  public MyPopUp(){
     InitializeComponent();
    }
}
</code>```

Below is the code for ViewModel> > MyPopUpViewModel.cs

```<code>public class MyPopUpViewModel: BindableBase
{
    public MyPopUpViewModel()
    {
        AddCommand = new DelegateCommand(AddCommandCall);

    }

    private void AddCommandCall()
    {
        /// Command call Code here
    }

    public DelegateCommand AddCommand { get; private set; }

}
</code>```

MyPopUp.xaml code here

```<code><Window x:Class="Project"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

      xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:local="clr-namespace:Project.PopUpControls"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
     xmlns:prism="http://prismlibrary.com/"

    mc:Ignorable="d"
    Title="Create Levels" Height="700" Width="900"
    prism:ViewModelLocator.AutoWireViewModel="True">

<Grid>
    <Button
        Command="{Binding DataContext.AddCommand}"
        Content="test"
        Margin="0,5,0,0"
        FontSize="16"
        FontWeight="Normal"
        Width="100"
        HorizontalAlignment="Center"
        HorizontalContentAlignment="Center"
        VerticalAlignment="Top"
        VerticalContentAlignment="Center"
        Foreground="#ffffff"
        Background="#4e4e4e"/>
</Grid>
</code>```

Though when InitializeComponent(); is called in MyPopUp.xaml.cs  the window DataContext get all the commands in it from MyPopUpViewModel.cs

Then when clicked on button on pop up... It should call the command AddCommand, but it is not getting called.

Let me know what I'm missing or sommnething need to be added/change.

Thanks in advance.

答:
I don't see in your codebehind or in xaml the call to your viewmodel. Maybe i'm wrong but for me you need to call after InitializeComponent() in codebehind ==> DataContext = new MyPoPupViewModel() !

Xaml call :

```<code>xmlns:local="clr-namespace:YourApplication"

<Window.DataContext>
   <local:MyPoPupViewModel/>
</Window.DataContext>
</code>```

Body:
How call a delegate command from window pop up.
I'm showing a pop up window over a window..
The pop up window have button which need to call DelegateCommand from ViewModel.

Below is the code for Window > MyPopUp.xaml.cs

public partial class MyPopUp : Window
{
  public MyPopUp(){
     InitializeComponent();
    }
}

Below is the code for ViewModel> > MyPopUpViewModel.cs

public class MyPopUpViewModel: BindableBase
{
    public MyPopUpViewModel()
    {
        AddCommand = new DelegateCommand(AddCommandCall);

    }

    private void AddCommandCall()
    {
        /// Command call Code here
    }

    public DelegateCommand AddCommand { get; private set; }

}

MyPopUp.xaml code here

<Window x:Class="Project"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

      xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:local="clr-namespace:Project.PopUpControls"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
     xmlns:prism="http://prismlibrary.com/"

    mc:Ignorable="d"
    Title="Create Levels" Height="700" Width="900"
    prism:ViewModelLocator.AutoWireViewModel="True">

<Grid>
    <Button
        Command="{Binding DataContext.AddCommand}"
        Content="test"
        Margin="0,5,0,0"
        FontSize="16"
        FontWeight="Normal"
        Width="100"
        HorizontalAlignment="Center"
        HorizontalContentAlignment="Center"
        VerticalAlignment="Top"
        VerticalContentAlignment="Center"
        Foreground="#ffffff"
        Background="#4e4e4e"/>
</Grid>

Though when InitializeComponent(); is called in MyPopUp.xaml.cs  the window DataContext get all the commands in it from MyPopUpViewModel.cs

Then when clicked on button on pop up... It should call the command AddCommand, but it is not getting called.

Let me know what I'm missing or sommnething need to be added/change.

Thanks in advance.

Body:
I don't see in your codebehind or in xaml the call to your viewmodel. Maybe i'm wrong but for me you need to call after InitializeComponent() in codebehind ==> DataContext = new MyPoPupViewModel() !

Xaml call :

xmlns:local="clr-namespace:YourApplication"

<Window.DataContext>
   <local:MyPoPupViewModel/>
</Window.DataContext>


问:
SQL query to get count of unique combinations in the table - MySql
I have a mapping table like below

```<code>c1  c2
--  --
1   1
1   1
1   2
1   3
1   3
2   1
2   2
2   3
3   1
</code>```

and so on. The table has a separate id column (not showed here).
Here is my query so far :

```<code>SELECT `c1`, `c2`, COUNT(*) AS `count_of_uniques` FROM `map_table`
GROUP BY `c1`, `c2`
</code>```

I have also tried with distinct query like this.

```<code>SELECT `c1`, `c2`, COUNT(DISTINCT `c1`, `c2`) AS `count_of_uniques` FROM `map_table`
</code>```

The expected result is

```<code>c1  c2  count_of_uniques
--  --  ----------------
1   1   2
1   2   2
1   3   3
2   2   1
2   3   1
</code>```

My current query shows the correct output when the combination is made of two similar numbers, but when we have something like 1-2 and 2-1, the query does not have the correct output.

distinct shows still fewer results.

Any help is greatly appreciated. Thank you.

答: Select C1,C2,Count(*) from map_table Group By C1,C2 Order by C1</p>

Body:
I have a mapping table like below

c1  c2
--  --
1   1
1   1
1   2
1   3
1   3
2   1
2   2
2   3
3   1

and so on. The table has a separate id column (not showed here).
Here is my query so far :

SELECT `c1`, `c2`, COUNT(*) AS `count_of_uniques` FROM `map_table`
GROUP BY `c1`, `c2`

I have also tried with distinct query like this.

SELECT `c1`, `c2`, COUNT(DISTINCT `c1`, `c2`) AS `count_of_uniques` FROM `map_table`

The expected result is

c1  c2  count_of_uniques
--  --  ----------------
1   1   2
1   2   2
1   3   3
2   2   1
2   3   1

My current query shows the correct output when the combination is made of two similar numbers, but when we have something like 1-2 and 2-1, the query does not have the correct output.

distinct shows still fewer results.

Any help is greatly appreciated. Thank you.


问:
Trying to generate Fibonacci series using recursive WITH clause, getting error: 'cycle detected while executing'
I am trying to generate Fibonacci series using below query (recursive WITH clause).

```<code>WITH X(Pnbr,Cnbr) AS
(SELECT 0, 1 FROM dual
 UNION ALL
 SELECT X.Cnbr, X.Pnbr+X.Cnbr FROM X
 WHERE X.Cnbr<50
)
 SELECT * FROM X
</code>```

But I am getting this error

```<code>ORA-32044: cycle detected while executing recursive WITH query
</code>```

Why?

答:
I agree with the diagnosis in M. Ravisankar's Answer (from 2015), but not with the remedy.

To handle precisely the situation presented in the original post, recursive CTE offers the CYCLE clause. In this problem, while there will be repeated values in the Pnbr column as well as in the Cnbr column, when considered separately, there are no repeated values (duplicates) in the composite (Pnbr, Cnbr).

So, the query can be written like this:

```<code>WITH X(Pnbr,Cnbr) AS
(SELECT 0, 1 FROM dual
 UNION ALL
 SELECT X.Cnbr, X.Pnbr+X.Cnbr FROM X
 WHERE X.Cnbr<50
)
cycle Pnbr, Cnbr set cycle to 'Y' default 'N'    ----
SELECT Pnbr, Cnbr FROM X
</code>```

Notice the cycle clause (second to last line), and also SELECT Pnbr, Cnbr as opposed to SELECT * (if we selected * here, we would also get the cycle column, which we don't need).

Body:
I am trying to generate Fibonacci series using below query (recursive WITH clause).

WITH X(Pnbr,Cnbr) AS
(SELECT 0, 1 FROM dual
 UNION ALL
 SELECT X.Cnbr, X.Pnbr+X.Cnbr FROM X
 WHERE X.Cnbr<50
)
 SELECT * FROM X

But I am getting this error

ORA-32044: cycle detected while executing recursive WITH query

Why?

Body:
I agree with the diagnosis in M. Ravisankar's Answer (from 2015), but not with the remedy.

To handle precisely the situation presented in the original post, recursive CTE offers the CYCLE clause. In this problem, while there will be repeated values in the Pnbr column as well as in the Cnbr column, when considered separately, there are no repeated values (duplicates) in the composite (Pnbr, Cnbr).

So, the query can be written like this:

WITH X(Pnbr,Cnbr) AS
(SELECT 0, 1 FROM dual
 UNION ALL
 SELECT X.Cnbr, X.Pnbr+X.Cnbr FROM X
 WHERE X.Cnbr<50
)
cycle Pnbr, Cnbr set cycle to 'Y' default 'N'    ----
SELECT Pnbr, Cnbr FROM X

Notice the cycle clause (second to last line), and also SELECT Pnbr, Cnbr as opposed to SELECT * (if we selected * here, we would also get the cycle column, which we don't need).


问:
Create dictionary with values that inherit from a superclass
I have multiple classes inheriting from a single class, is it possible to  create a dictionary map for them? So I can reference the correct class given a string key.

let map = [String: EngineView] = [
  "google": GoogleView,
  "duckduckgo": DuckDuckGoView
]
```

GoogleView and DuckDuckGoView both subclass EngineView but XCode complains:

"Cannot convert value of type 'GoogleView.Type' to expected dictionary value type 'EngineView'"

答:
Assuming that GoogleView and DuckDuckGoView inherit from EngineView you can do something like this:

```<code>let map = [String: EngineView.Type] = [
  "google": GoogleView.self,
  "duckduckgo": DuckDuckGoView.self
]
</code>```

Usage

```<code>if let aClass = map["google"] {
    let instance = aClass.init()
}
</code>```

Body:
I have multiple classes inheriting from a single class, is it possible to  create a dictionary map for them? So I can reference the correct class given a string key.

let map = [String: EngineView] = [
  "google": GoogleView,
  "duckduckgo": DuckDuckGoView
]

GoogleView and DuckDuckGoView both subclass EngineView but XCode complains:

"Cannot convert value of type 'GoogleView.Type' to expected dictionary value type 'EngineView'"

Body:
Assuming that GoogleView and DuckDuckGoView inherit from EngineView you can do something like this:

let map = [String: EngineView.Type] = [
  "google": GoogleView.self,
  "duckduckgo": DuckDuckGoView.self
]

Usage

if let aClass = map["google"] {
    let instance = aClass.init()
}


问:
Collecting the Azure Diagnosis Log Remotely without the support of Storage Account
I have a use case where I need the Diagnostics and Performance data of the Azure Web-Role to be monitored remotely which is to be done without any Storage Account.

答:
Adding to Stuart's answer: the Diagnostic Monitor is set up to collect counters, logs, and diagnostics locally and aggregate them into well-known Azure Storage tables, so this requires a storage account. If you wrote a background process to periodically poll local counters, you could then push them from your instances to pretty much anywhere you want: SQL Azure, SQL Server (on premise), web service, email, etc. However, as Stuart says, this feels like reinventing the wheel.

The Diagnostic Monitor aggregates counters across all of your instances, letting you easily aggregate counter values across all of your web roles, for instance, or letting you drill down on a specific instance easily.

Not sure why you'd want to avoid a storage account for diagnostics. At $0.15/GB, it's going to have very low cost overhead, especially if you're only storing diagnostic data. Plus, 3rd party monitoring tools (such as AzureWatch) need to pull counters from your storage account.


问:
Custom checkout billing field on email notifications
In WooCommerce, based on "Dynamic synched custom checkout select fields in WooCommerce" answer code, I am adding some custom fields on checkout which will be displayed under the billing section on the e-mail confirmation

Here is my actual code:

```<code>add_action( 'woocommerce_after_checkout_billing_form', 'add_checkout_custom_fields', 20, 1 );
function add_checkout_custom_fields( $checkout) {
    $domain = 'woocommerce'; // The domain slug

    // First Select field (Master)
    woocommerce_form_field( 'delivery_one', array(
        'type'          => 'select',
        'label'         => __( 'Art der Lieferung' , $domain),
        'class'         => array( 'form-row-first' ),
        'required'       => true,
        'options'       => array(
            ''  => __( 'Wählen Art der Lieferung.', $domain ),
            'A' => __( 'Hauszustellung', $domain ),
            'B' => __( 'Selbst Abholung', $domain ),

        ),
    ), $checkout->get_value( 'delivery_one' ) );

    // Default option value
    $default_option2 = __( 'Wählen Sie Zeitbereich.', $domain );

    // Dynamic select field options for Javascript/jQuery
    $options_0 = array( '' => $default_option2 );
    $options_a = array(
        ''  => $default_option2,
        '1' => __( '09:00-11:00', $domain ),
        '2' => __( '10:00-12:00', $domain ),
        '3' => __( '11:00-13:00', $domain ),
        '4' => __( '12:00-14:00', $domain ),
        '5' => __( '13:00-15:00', $domain ),
        '6' => __( '14:00-16:00', $domain ),
        '7' => __( '15:00-17:00', $domain ),
    );

    $options_b = array(
        ''  => $default_option2,
        '1' => __( '01:00', $domain ),
        '2' => __( '02:00', $domain ),
        '3' => __( '03:00', $domain ),
        '4' => __( '04:00', $domain ),
        '5' => __( '05:00', $domain ),
        '6' => __( '06:00', $domain ),
        '7' => __( '07:00', $domain ),
        '8' => __( '08:00', $domain ),
        '9' => __( '09:00', $domain ),
        '10' => __( '10:00', $domain ),
        '11' => __( '11:00', $domain ),
        '12' => __( '12:00', $domain ),
        '13' => __( '13:00', $domain ),
        '14' => __( '14:00', $domain ),
        '15' => __( '15:00', $domain ),
        '16' => __( '16:00', $domain ),
        '17' => __( '17:00', $domain ),
        '18' => __( '18:00', $domain ),
        '19' => __( '19:00', $domain ),
        '20' => __( '20:00', $domain ),
        '21' => __( '21:00', $domain ),
        '22' => __( '22:00', $domain ),
        '23' => __( '23:00', $domain ),
        '24' => __( '24:00', $domain ),
    );

    // Second Select field (Dynamic Slave)
    woocommerce_form_field( 'delivery_two', array(
        'type'          => 'select',
        'label'         => __( 'Zeitspanne', $domain ),
        'class'         => array( 'form-row-last' ),
        'required'       => true,
        'options'       => $options_0,
    ), $checkout->get_value( 'delivery_two' ) );

    $required = esc_attr__( 'required', 'woocommerce' );

    // jQuery code
    ?>
    <script>
    jQuery(function($){
        var op0 = <?php echo json_encode($options_0); ?>,
            opa = <?php echo json_encode($options_a); ?>,
            opb = <?php echo json_encode($options_b); ?>,

            select1 = 'select[name="delivery_one"]',
            select2 = 'select[name="delivery_two"]';

        // Utility function to fill dynamically the select field options
        function dynamicSelectOptions( opt ){
            var options = '';
            $.each( opt, function( key, value ){
                options += '<option value="'+key+'">'+value+'</option>';
            });
            $(select2).html(options);
        }

        // 1. When dom is loaded we add the select field option for "A" value
        // => Disabled (optional) — Uncomment below to enable
        // dynamicSelectOptions( opa );

        // 2. On live selection event on the first dropdown
        $(select1).change(function(){
            if( $(this).val() == 'A' )
                dynamicSelectOptions( opa );
            else if( $(this).val() == 'B' )
                dynamicSelectOptions( opb );

            else
                dynamicSelectOptions( op0 ); // Reset to default
        });
    });
    </script>
    <?php
}

// Check checkout custom fields
add_action( 'woocommerce_checkout_process', 'wps_check_checkout_custom_fields', 20 ) ;
function wps_check_checkout_custom_fields() {
    // if custom fields are empty stop checkout process displaying an error notice.
    if ( empty($_POST['delivery_one']) || empty($_POST['delivery_two']) ){
        $notice = __( 'Bitte wählen Sie die Versandart oder den Stundenbereich' );
        wc_add_notice( '<strong>' . $notice . '</strong>', 'error' );
    }
}
</code>```

My custom fields and their values, are shown on the checkout form and on the order pages on back end. So far everything works great.

But the problem is that the e-mail that I receive does not contain the custom fields and their values.

How can I display that custom checkout billing fields on email notifications?

Is this code correct?

```<code>add_filter( 'woocommerce_email_format_string' , 'add_custom_email_format_string', 20, 2 );
  function add_custom_email_format_string( $string, $email ) {
// The post meta key used to save the value in the order post meta data
$meta_key = '_delivery_one';

// Get the instance of the WC_Order object
$order    = $email->object;

// Get the value
$value = $order->get_meta($meta_key) ? $order->get_meta($meta_key) : '';

// Additional subject placeholder
$new_placeholders = array( '{delivery_one}' => $value );

return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
 }
</code>```

答:
You should first save input value at the database as an order meta see here and then you can get the meta value in email template. All the email template of woocommerce is customizable and located at plugins/woocommerce/emails/

You can use this hook to store custom input field at order meta

```<code>do_action( 'woocommerce_checkout_order_processed', $order_id, $posted_data, $order );
</code>```

Thanks

Body:
In WooCommerce, based on "Dynamic synched custom checkout select fields in WooCommerce" answer code, I am adding some custom fields on checkout which will be displayed under the billing section on the e-mail confirmation

Here is my actual code:

add_action( 'woocommerce_after_checkout_billing_form', 'add_checkout_custom_fields', 20, 1 );
function add_checkout_custom_fields( $checkout) {
    $domain = 'woocommerce'; // The domain slug

    // First Select field (Master)
    woocommerce_form_field( 'delivery_one', array(
        'type'          => 'select',
        'label'         => __( 'Art der Lieferung' , $domain),
        'class'         => array( 'form-row-first' ),
        'required'       => true,
        'options'       => array(
            ''  => __( 'Wählen Art der Lieferung.', $domain ),
            'A' => __( 'Hauszustellung', $domain ),
            'B' => __( 'Selbst Abholung', $domain ),

        ),
    ), $checkout->get_value( 'delivery_one' ) );

    // Default option value
    $default_option2 = __( 'Wählen Sie Zeitbereich.', $domain );

    // Dynamic select field options for Javascript/jQuery
    $options_0 = array( '' => $default_option2 );
    $options_a = array(
        ''  => $default_option2,
        '1' => __( '09:00-11:00', $domain ),
        '2' => __( '10:00-12:00', $domain ),
        '3' => __( '11:00-13:00', $domain ),
        '4' => __( '12:00-14:00', $domain ),
        '5' => __( '13:00-15:00', $domain ),
        '6' => __( '14:00-16:00', $domain ),
        '7' => __( '15:00-17:00', $domain ),
    );

    $options_b = array(
        ''  => $default_option2,
        '1' => __( '01:00', $domain ),
        '2' => __( '02:00', $domain ),
        '3' => __( '03:00', $domain ),
        '4' => __( '04:00', $domain ),
        '5' => __( '05:00', $domain ),
        '6' => __( '06:00', $domain ),
        '7' => __( '07:00', $domain ),
        '8' => __( '08:00', $domain ),
        '9' => __( '09:00', $domain ),
        '10' => __( '10:00', $domain ),
        '11' => __( '11:00', $domain ),
        '12' => __( '12:00', $domain ),
        '13' => __( '13:00', $domain ),
        '14' => __( '14:00', $domain ),
        '15' => __( '15:00', $domain ),
        '16' => __( '16:00', $domain ),
        '17' => __( '17:00', $domain ),
        '18' => __( '18:00', $domain ),
        '19' => __( '19:00', $domain ),
        '20' => __( '20:00', $domain ),
        '21' => __( '21:00', $domain ),
        '22' => __( '22:00', $domain ),
        '23' => __( '23:00', $domain ),
        '24' => __( '24:00', $domain ),
    );

    // Second Select field (Dynamic Slave)
    woocommerce_form_field( 'delivery_two', array(
        'type'          => 'select',
        'label'         => __( 'Zeitspanne', $domain ),
        'class'         => array( 'form-row-last' ),
        'required'       => true,
        'options'       => $options_0,
    ), $checkout->get_value( 'delivery_two' ) );

    $required = esc_attr__( 'required', 'woocommerce' );

    // jQuery code
    ?>

    <?php
}

// Check checkout custom fields
add_action( 'woocommerce_checkout_process', 'wps_check_checkout_custom_fields', 20 ) ;
function wps_check_checkout_custom_fields() {
    // if custom fields are empty stop checkout process displaying an error notice.
    if ( empty($_POST['delivery_one']) || empty($_POST['delivery_two']) ){
        $notice = __( 'Bitte wählen Sie die Versandart oder den Stundenbereich' );
        wc_add_notice( '' . $notice . '', 'error' );
    }
}

My custom fields and their values, are shown on the checkout form and on the order pages on back end. So far everything works great.

But the problem is that the e-mail that I receive does not contain the custom fields and their values.

How can I display that custom checkout billing fields on email notifications?

Is this code correct?

add_filter( 'woocommerce_email_format_string' , 'add_custom_email_format_string', 20, 2 );
  function add_custom_email_format_string( $string, $email ) {
// The post meta key used to save the value in the order post meta data
$meta_key = '_delivery_one';

// Get the instance of the WC_Order object
$order    = $email->object;

// Get the value
$value = $order->get_meta($meta_key) ? $order->get_meta($meta_key) : '';

// Additional subject placeholder
$new_placeholders = array( '{delivery_one}' => $value );

return str_replace( array_keys( $additional_placeholders ), array_values( $additional_placeholders ), $string );
 }

Body:
You should first save input value at the database as an order meta see here and then you can get the meta value in email template. All the email template of woocommerce is customizable and located at plugins/woocommerce/emails/

You can use this hook to store custom input field at order meta

do_action( 'woocommerce_checkout_order_processed', $order_id, $posted_data, $order );

Thanks


问:
Record Audio on OSX (AVAudioSession not available)
I am looking to capture audio on OSX. I have IOS working with AVAudioSession, but since it is not supported on OSX, I'm having difficulty finding a simple example on OSX to record audio to a file for subsequent playback.

All the examples I find on stackoverflow have been IOS and or not in Swift.

Any help here would be appreciated. A link to a OSX Swift based simple audio capture sample code would be great.

Thanks Tom

答: The Audio Queue API works for recording on both iOS and macOS (OSX).  So look for an Audio Queue example; there appear to be several on github.</p>


问:
Check if element is occurring very first time in python list
I have a list with values occurring multiple times. I want to loop over the list and check if value is occurring very first time.

For eg: Let's say I have a one list like ,

L = ['a','a','a','b','b','b','b','b','e','e','e'.......]

Now, at every first occurrence of element, I want to perform some set of tasks.

How to get the first occurrence of element?

Thanks in Advance!!

答:
Use a set to check if you had processed that item already:

```<code>visited = set()
L = ['a','a','a','b','b','b','b','b','e','e','e'.......]
for e in L:
    if e not in visited:
        visited.add(e)
        # process first time tasks
    else:
        # process not first time tasks
</code>```

Body:
Use a set to check if you had processed that item already:

visited = set()
L = ['a','a','a','b','b','b','b','b','e','e','e'.......]
for e in L:
    if e not in visited:
        visited.add(e)
        # process first time tasks
    else:
        # process not first time tasks


问:
count items in an one array, if the number of instances is the same as the length of a different array, return the item, javascript
I have two arrays, id like to return the items from array1 if they appear as much as the length of array2

I understand how to do this in python, but I cant figure out how to do it in javascript

arr1 = ['a', 'b', 'c', 'c']
arr2 = ['one', 'two']
arr3 = []
```

<pre class="lang-py prettyprint-override"><code>for i in arr1:
    if arr1.count(i) == len(arr2):
    arr3.append(i)
</code>```

desired result would be ['c']

Can someone please help me write this in javascript?

答:
You can use reduce and filter

Here idea is :-

First use elements of arr1 as key on obj, if key is already there increment it's value, else set it to zero,

Now take the key's of obj and filter if it's value is equal to length of arr2

let arr1 = ['a', 'b', 'c', 'c']
let arr2 = ['one', 'two']

let obj = arr1.reduce((op,inp)=>{
  let key = inp.toLowerCase()
  op[key] = op[key] || 0
  op[key]++
  return op
},{})

let final = Object.keys(obj).filter(key=>{
  return obj[key] === arr2.length
})

console.log(final)```
</div>
</div>
</p>

<p><strong>Note :-</strong> Here i ignored case, if you want both case to be different than you can remove this line</p>

```  let key = inp.toLowerCase()
```

Body:
I have two arrays, id like to return the items from array1 if they appear as much as the length of array2

I understand how to do this in python, but I cant figure out how to do it in javascript

arr1 = ['a', 'b', 'c', 'c']
arr2 = ['one', 'two']
arr3 = []

for i in arr1:
    if arr1.count(i) == len(arr2):
    arr3.append(i)

desired result would be ['c']

Can someone please help me write this in javascript?

Body:
You can use reduce and filter

Here idea is :-

First use elements of arr1 as key on obj, if key is already there increment it's value, else set it to zero,

Now take the key's of obj and filter if it's value is equal to length of arr2

let arr1 = ['a', 'b', 'c', 'c']
let arr2 = ['one', 'two']

let obj = arr1.reduce((op,inp)=>{
  let key = inp.toLowerCase()
  op[key] = op[key] || 0
  op[key]++
  return op
},{})

let final = Object.keys(obj).filter(key=>{
  return obj[key] === arr2.length
})

console.log(final)

Note :- Here i ignored case, if you want both case to be different than you can remove this line

  let key = inp.toLowerCase()


答:
First use reduce() to create object of whose keys will elements of arr1 and value will be their count. Then filter() its keys according to given condition.

let arr1 = ['a', 'b', 'c', 'c']
let arr2 = ['one', 'two']

const obj = arr1.reduce((ac,a) => (ac[a] = ac[a] + 1 || 1, ac),{});

let res = Object.keys(obj).filter(k => obj[k] === arr2.length);
console.log(res)```

Title: count items in an one array, if the number of instances is the same as the length of a different array, return the item, javascript


问:
Case When with Count inside an ON clause of a JOIN
Inside the JOIN (BB_VENDASDOCUMENTOS VD), I need to choose if VD.ENTRADASAIDA will be 'S' or 'E', what I actually need is, if there is at least one BB_VENDASDOCUMENTOS where ENTRADASAIDA = 'S', use 'S', else 'N'

I've tried to do a CASE WHEN counting the numer of VD.ENTRADASAIDA = 'S', if there is more then 0, It will use 'S', else 'N', but I'm getting an error that and aggregate cannot appear in an ON clause...

```<code>SELECT
 CASE WHEN CENTROCUSTO.DESCRICAO IS NOT NULL THEN CENTROCUSTO.DESCRICAO + '|' ELSE '' END AS [text()]
                                                  FROM BB_PNRACCOUNTINGS ACC1
                                                  JOIN BB_VENDASDOCUMENTOS VD
                                                    ON ( VD.ACCOUNTING = ACC1.HANDLE
                                                                AND  VD.ENTRADASAIDA = CASE WHEN count(case when VD.ENTRADASAIDA = 'S' THEN 1 ELSE NULL END ) > 0 THEN 'S'  ELSE 'E'  END
                                                    AND  VD.PESSOA = ACC1.BB_CLIENTE
                                                    AND ( ( VD.CANCELADO = 'N' ) OR (VD.CANCELADO IS NULL) ) )
                                                  LEFT JOIN BB_CLIENTECC CENTROCUSTO
                                                    ON (CENTROCUSTO.Handle = VD.CENTRODECUSTO)
                                                                  WHERE CENTROCUSTO.DESCRICAO IS NOT NULL
</code>```

答:
You will need to scan the table twice. Once to mark each group with a S or E and then to gather only the records that match the condition. I would do this by joining on a subquery and then join again on the condition. I am not sure the syntax below is 100% correct, however, the basic concept is there.</p>

```<code>;WITH BB_VENDASDOCUMENTOSCalc AS
(
    SELECT ACCOUNTING,PESSOA,
        ENTRADASAIDACalc = count(case when ENTRADASAIDA = 'S' THEN 1 ELSE NULL END ) > 0 THEN 'S'  ELSE 'E'  END
    FROM
        BB_VENDASDOCUMENTOS
    WHERE
        (CANCELADO='N' OR CANCELADO IS NULL)
    GROUP BY
        ACCOUNTING,
        PESSOA
    )
SELECT
 CASE WHEN CENTROCUSTO.DESCRICAO IS NOT NULL THEN CENTROCUSTO.DESCRICAO + '|' ELSE '' END AS [text()]
                                                  FROM BB_PNRACCOUNTINGS ACC1
                                                  JOIN BB_VENDASDOCUMENTOSCalc VD1 ON VD1.ACCOUNTING = ACC1.HANDLE AND VD1.PESSOA = ACC1.BB_CLIENTE
                                                  JOIN BB_VENDASDOCUMENTO VD ON  VD.ACCOUNTING = ACC1.HANDLE AND VD.PESSOA = ACC1.BB_CLIENTE AND VD.ENTRADASAIDA = VD1.ENTRADASAIDACalc
                                                  LEFT JOIN BB_CLIENTECC CENTROCUSTO
                                                    ON (CENTROCUSTO.Handle = VD.CENTRODECUSTO)
                                                                  WHERE CENTROCUSTO.DESCRICAO IS NOT NULL
</code>```

Body:
Inside the JOIN (BB_VENDASDOCUMENTOS VD), I need to choose if VD.ENTRADASAIDA will be 'S' or 'E', what I actually need is, if there is at least one BB_VENDASDOCUMENTOS where ENTRADASAIDA = 'S', use 'S', else 'N'

I've tried to do a CASE WHEN counting the numer of VD.ENTRADASAIDA = 'S', if there is more then 0, It will use 'S', else 'N', but I'm getting an error that and aggregate cannot appear in an ON clause...

SELECT
 CASE WHEN CENTROCUSTO.DESCRICAO IS NOT NULL THEN CENTROCUSTO.DESCRICAO + '|' ELSE '' END AS [text()]
                                                  FROM BB_PNRACCOUNTINGS ACC1
                                                  JOIN BB_VENDASDOCUMENTOS VD
                                                    ON ( VD.ACCOUNTING = ACC1.HANDLE
                                                                AND  VD.ENTRADASAIDA = CASE WHEN count(case when VD.ENTRADASAIDA = 'S' THEN 1 ELSE NULL END ) > 0 THEN 'S'  ELSE 'E'  END
                                                    AND  VD.PESSOA = ACC1.BB_CLIENTE
                                                    AND ( ( VD.CANCELADO = 'N' ) OR (VD.CANCELADO IS NULL) ) )
                                                  LEFT JOIN BB_CLIENTECC CENTROCUSTO
                                                    ON (CENTROCUSTO.Handle = VD.CENTRODECUSTO)
                                                                  WHERE CENTROCUSTO.DESCRICAO IS NOT NULL

Body:
You will need to scan the table twice. Once to mark each group with a S or E and then to gather only the records that match the condition. I would do this by joining on a subquery and then join again on the condition. I am not sure the syntax below is 100% correct, however, the basic concept is there.

;WITH BB_VENDASDOCUMENTOSCalc AS
(
    SELECT ACCOUNTING,PESSOA,
        ENTRADASAIDACalc = count(case when ENTRADASAIDA = 'S' THEN 1 ELSE NULL END ) > 0 THEN 'S'  ELSE 'E'  END
    FROM
        BB_VENDASDOCUMENTOS
    WHERE
        (CANCELADO='N' OR CANCELADO IS NULL)
    GROUP BY
        ACCOUNTING,
        PESSOA
    )
SELECT
 CASE WHEN CENTROCUSTO.DESCRICAO IS NOT NULL THEN CENTROCUSTO.DESCRICAO + '|' ELSE '' END AS [text()]
                                                  FROM BB_PNRACCOUNTINGS ACC1
                                                  JOIN BB_VENDASDOCUMENTOSCalc VD1 ON VD1.ACCOUNTING = ACC1.HANDLE AND VD1.PESSOA = ACC1.BB_CLIENTE
                                                  JOIN BB_VENDASDOCUMENTO VD ON  VD.ACCOUNTING = ACC1.HANDLE AND VD.PESSOA = ACC1.BB_CLIENTE AND VD.ENTRADASAIDA = VD1.ENTRADASAIDACalc
                                                  LEFT JOIN BB_CLIENTECC CENTROCUSTO
                                                    ON (CENTROCUSTO.Handle = VD.CENTRODECUSTO)
                                                                  WHERE CENTROCUSTO.DESCRICAO IS NOT NULL