How do I append only distinct records from a master table to another table, when the master may have duplicates. Example - I only want the distinct records in the smaller table but I need to insert/append records to what I already have in the smaller table.
...
I have 3 tables:
Vehicle: vehicle_id, vehicle_type
1, motorcycle
2, car
3, van
Owners: person_id, vehicle_id, date_bought
1, 1, 2009
1, 2, 2008
2, 3, 2009
2, 1, 2005
I want to display a list of all vehicle names. If the person_id = 1, date_bought should also be returned.
So I thought I would start with this:
SELECT * FROM vehicles
...
I want to accomplish something of the following:
Select DISTINCT(tableA.column) INTO tableB.column FROM tableA
The goal would be to select a distinct data set and then insert that data into a specific column of a new table.
...
I want to select distinct product_series, but I want all the other columns too.
This is my query as it stands:
SELECT DISTINCT product_series
FROM cart_product
WHERE product_brand = "everlon"
AND product_type = "ring"
AND product_available = "yes"
But this only gives me product_series, but I need all the other columns in that row...
I am trying to get a results that will show Uniuque "Reasons", the number of them there are, and the percentage of the total that they are. so far I have
SELECT DISTINCT Reason,
COUNT(Reason) AS Number,
CAST(COUNT(Reason) AS float) / CAST(COUNT(*) AS float) AS percentage
FROM DeletedClients
However as I have discovered...
Hi,
I have three models: Product, Category and Place.
Product has ManyToMany relation with Category and Place.
I need to get a list of categories with at least on product matching a specific place.
For example I might need to get all the categories that has at least one product from Boston.
I have 100 categories, 500 places and 100,000...
I have a little SQL Distinct puzzle that i cannot solve (or at least not in an very elegant way).
I have two tables (try to ignore the simplicity of the example). I'm using MSSQL 2008 if that makes much of a difference.
Table: Category
| categoryId (uniqueidentifier) PK |
| Name varchar(50) |
Table: Download
| do...
I have a table GL that contains GLCode. I need to get a list of unique GLCodes, but get all the other columns. The following SQL produces the results I want.
select * from GL where GLId in (select Min(GLId) from GL group by GLCode )
Is there a way to do this using the Criteria API?
This is my best attempt:
var subQuery = Det...
I have two mysql tables - a sales table:
+----------------+------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------------------+------+-----+---------+-------+
| StoreId | bigint(20) unsigned | NO ...
Hello all,
I am working with some large XML files using LINQ to XML. Now, a typical XML file returns:
ID
Name
Image URL
I get a lot of duplicate information, I consider duplicate information to be data with the same ID ( it could have different a name and images and I don't mind). I want to distinct the values of the first XML file ...
Is it possible to get the distinct elements of a List based on a property of the objects in the List?
Someting like: Distinct(x => x.id)
What's not usefull for me is following: .Select(x => x.id).Distinct() because then I would get back a List<int> instead of List<MyClass>
...
Hello Everybody!!
I have a large table(60 columns, 1.5 million records) of denormalized data in MS SQL 2005 that was imported from an Access database. I've been tasked with normalizing and inserting this data into our data model.
I would like to create a query that used a grouping of, for example "customer_number", and returned a re...
Given the following XML:
<interface name="Serial1/0"/>
<interface name="Serial2/0.0"/>
<interface name="Serial2/0.1"/>
<interface name="Serial3/0:0"/>
<interface name="Serial3/0:1"/>
I am trying to produce the following output:
<interface name="Serial1/0">
<unit name="Serial1/0"/>
</interface>
<interface name="Serial2/0">
<unit n...
This extends from http://stackoverflow.com/questions/2133459/xml-to-xml-using-xsl-problem
I managed to import exslt and modified my codes according to the solution (thanks to Kyle Butt) given as follows:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:func="http://exslt....
Hello all,
I have a Journal_Entry table, with a Primary Key of Journal_Entry_ID, and (among other columns) an Entry_Date column.
I'm trying to do a query that selects the most recent Entry_Date -- via a SELECT MAX(Entry_Date) -- but the problem is that the user may have logged more than one entry on a given date. So if the user logged ...
I am sure I am looking at this in the wrong way.
I would like to hold a restaurant menu in a database and display it. For example, I have created a table similar to the one below:
Columns:
Food_Item | Food_Description | Food_Price | Food_CAT.
Data:
Salad | Refreshing Salad | 5.25 | Starters
Prawn Cocktail | Lovely Prawns | 4.75...
I'm designing a query in SSMS 2005 which looks something like this:
SELECT COUNT(DISTINCT ColumnName) FROM Table WHERE ColumnName IS NOT NULL
When I run the query with COUNT() it returns the value 1. When I run it without COUNT(), SSMS reports the correct value eg 212 records.
The column in question is of datatype numeric(16, 0).
Fo...
Hey there,
I have a CATEGORIES table that links to an ITEMS table (one to many). Each item table could have multiple barcodes in the BARCODES table (one to many).
The idea is that a new barcode may be added against an item at some point, but the old data is stored in the BARCODES table so that if a search is done with an order with las...
Using Python, I'm trying to convert a sentence of words into a flat list of all distinct letters in that sentence.
Here's my current code:
words = 'She sells seashells by the seashore'
ltr = []
# Convert the string that is "words" to a list of its component words
word_list = [x.strip().lower() for x in words.split(' ')]
# Now conver...
Hi there,
I'm stuck on a problem with sql. I have a table with many duplicate entries with column names like:-
eventnumber housenumber value1 value2
None of these column names are the primary key as there are many duplicates. What I would like to do is select into another table by distinct housenumber but I seem to get the whole tabl...