distinct

SQL - Return all Rows Where at Least one has value 'Y'

空扰寡人 提交于 2020-08-10 04:16:05
问题 My question is very similar to this previous post SQL Query, get a columns if another columns equal to x The only difference is I am joining two tables and the previous solution does not seem to work. Basically I have two Columns once the tables have been joined. I want all rows of a name, where at least one row for that name has "Shasta" as a location. For example, Column 1 = Name (From Table 1) Column 2 = Location (From Table 2) Name | Location ------------------- Bob | Shasta Bob | Leaves

Finding The Max of sum of elements in matrix in distinct rows and columns

三世轮回 提交于 2020-07-06 11:21:18
问题 I have a nxm matrix and I need to find the maximum of sum of its values in distinct rows and columns. For example considering the following Matrix: m1 m2 m3 n1 1 2 3 n2 4 5 6 n3 7 8 9 n4 10 11 12 The max will be 12+8+4 = 24 Note that finding the max and eliminating all values belonging to that column or row is not a good solution as it doesn't work for all cases. The exception for above will be the following: m1 m2 n1 17 1 n2 18 15 If you find 18 and remove 17 and 15, the sum will be 18+1 =

Finding The Max of sum of elements in matrix in distinct rows and columns

百般思念 提交于 2020-07-06 11:18:21
问题 I have a nxm matrix and I need to find the maximum of sum of its values in distinct rows and columns. For example considering the following Matrix: m1 m2 m3 n1 1 2 3 n2 4 5 6 n3 7 8 9 n4 10 11 12 The max will be 12+8+4 = 24 Note that finding the max and eliminating all values belonging to that column or row is not a good solution as it doesn't work for all cases. The exception for above will be the following: m1 m2 n1 17 1 n2 18 15 If you find 18 and remove 17 and 15, the sum will be 18+1 =

Count distinct values in excel with criteria on another column

冷暖自知 提交于 2020-06-01 06:18:39
问题 I need a formula to count distinct IDs from a table, based on Point Of Sale name with a wildcard, eg I need to find all distinct IDs from the table below, titles of POS of which contain word "China*". The result must be 4 (3333,4444,5555,1010). Thanks for your help. 回答1: It's widely known that Frequency is much quicker. So if your IDs are numeric, you can use =SUM(--(FREQUENCY(IF(ISNUMBER(SEARCH("China",A2:A10)),B2:B10),B2:B10)>0)) which must be entered as an array formula using Ctrl Shift

Count distinct values in excel with criteria on another column

不问归期 提交于 2020-06-01 06:18:23
问题 I need a formula to count distinct IDs from a table, based on Point Of Sale name with a wildcard, eg I need to find all distinct IDs from the table below, titles of POS of which contain word "China*". The result must be 4 (3333,4444,5555,1010). Thanks for your help. 回答1: It's widely known that Frequency is much quicker. So if your IDs are numeric, you can use =SUM(--(FREQUENCY(IF(ISNUMBER(SEARCH("China",A2:A10)),B2:B10),B2:B10)>0)) which must be entered as an array formula using Ctrl Shift

Count distinct by group- moving window

橙三吉。 提交于 2020-05-08 15:38:11
问题 Let's say I have a dataset contain visits in a hospital. My goal is to generate a variable that counts the number of unique patients the visitor has seen before at the date of the visit. I often work with group_by by dplyr but this seems a little tricky. I guess I would have to use group_by, n_distinct, and sum or some kind moving window command. The "goal" variable is what I need. visitor visitdt patient goal 125469 1/12/2018 15200 1 125469 1/19/2018 15200 1 125469 2/16/2018 15200 1 125469 2