distinct-values

Excel VBA: Subtotals?

I have data of this form: Category Source Amount Dues FTW $100 Donations ODP $20 Donations IOI $33 Dues MMK $124 Where there is no sort order. I want a VBA macro to cycle through the range, output a list of distinct values, with the subtotals for each. For the above d...

how to display all the distinct 7-digit number among 2 to 9?

what i mean is all the numbers _ _ _ _ _ _ _ are distinct and only values 2 to 9 can be entered. I've tried using array and loops but i just couldn't figure out the solution to display all the numbers. examples 7-digit number among 2 to 9 are: 234567 234568 234569 324567 324568 324569 notice the none of the numbers in those values are...

What is the most efficient way to create a distinct list of items using .NET?

I have a large list of values (100-200 character strings) and I need to return a distinct listing of them. What is the most efficient way to do this using .NET? The 2 ways that I can think of are: Use the Distinct() method of the IEnumerable class Use a Dictionary If the Dictionary approach is faster in raw terms, consider a trade-...

sql join - only select top row from 2nd table...

Bit of an sql noob, have a list in table a of customercodes/phone numbers, and table b has all the call records. I want to select the most recent call from table b for each of the customercodes/phone numbers in table a. So far I have: SELECT A.CustomerCode, A.PhoneNumber, B.StartTime FROM tableA A INNER JOIN t...

Getting a distinct value across 2 union sql server tables...

I know this is a silly question, but Im a newb I'm trying to get all distinct values across 2 tables using a union... The idea is to get a count of all unique values in the columnA column without repeats so that I can get a summation of all columns that contain a unique columnA... sounds simple eh? THis is what I tried (sql server expr...

not including null values in sql join

Hi, I have two tables CustomerAddress(CustomerId, City, Country) and CustomerTransactions(TransactionId, CustomerId, CustomerContact). Here are the values in the tables: For CustomerAddress: 1001, El Paso, USA 1002, Paris, France 1003, Essen, Germany For CustomerTransactions: 98, 1001, Phillip 99, 1001, NULL 100, 100...

Select distinct values from two columns

I have a table with the following structure: itemId | direction | uid | created 133 0 17 1268497139 432 1 140 1268497423 133 0 17 1268498130 133 1 17 1268501451 I need to select distinct values for two columns - itemId and direction, so the output would be lik...

distinct on a single column, yet returning a row from the same table based on an unselected condition

I am new to Sql server, and my MySql background is only decent, nothing exceptional. I have a table with 5 columns: Neighbrhood City State zip_code zip_percent The goal of the query: To provide a list of neighborhoods (unique) within a city and the zip_code that corresponds with the highest zip_percent. Thus returning 2 columns: Nei...

Counting distinct items in XSLT

I have XML like this: <assessment> <variables> <variable> <attributes> <variable_name value="FRED"/> </attributes> </variable> </variables> <variables> <variable> <attributes> <variable_name value="MORTIMER"/> </attributes> </variable> </variables> <variables> <variable> <attributes> <variable_n...

Counting distinct items in XSLT independent of depth

If I run the following XSLT code: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; <xsl:output method="text"/> <xsl:key name="kValueByVal" match="variable_name/@value" use="."/> <xsl:template match="assessment"> <xsl:for-each select=" /*/*/variable/attributes/variable_name/@value ...

T-SQL Distinct column problem when trying to filter duplicates out

I have the following data COL-1 COL-2 1 0TY/OK 1 0TY/OK 1 0TY/OK 1 0TY/OK 1 0TY/OK 2 2KP/L 2 2KP/L 2 2KP/L 2 2KP/L 2 2KP/L 3 7U5/2M 3 7U5/2M 3 7U5/2M 3 7U5/2M And i want to construct a select query to ret...

SQL eleminate mulitple value(s) if same identifier has a associated NULL value

Ok here goes: I have a table with id ( can be duplicate but not NULL ) and value ( can be duplicate and NULL ) id value ----- ----- 1 red 1 red 1 (null) 2 blue 2 blue 3 (null) So how do I return the id's and value's of all the records that have a value, but if a null value is also found don'...

Selecting all values from row based on one distinct column

Hi! I've been browsing the forums a while trying to find a solution to my issue. I have a table in SQL Server 2000 called result with the following data; City Price DepDate RetDate Barcelona 145 2010-05-15 2010-05-20 New York 400 2010-06-20 2010-06-20 Barcelona 160 2010-05-17 2010-05-22 New York 325 2010-05-...

Getting distinct list of ID's in CoreData

What's the most efficient way to perform this query on a CoreData table? To use the standard employees database model -- I want DISTINCT department ID's for all departments that contain employees with job-description "chef." As it happens, there is only a single table (Employees) relevant here -- I don't actually have a departments tab...

Linq join on parameterized distinct key

I'm trying to LINQ two tables based on a dynamic key. User can change key via a combo box. Key may be money, string, double, int, etc. Currently I'm getting the data just fine, but without filtering out the doubles. I can filter the double in VB, but it's slooooow. I'd like to do it in the LINQ query right out of the gate. Here's the da...