Click here to Skip to main content
15,889,992 members
Home / Discussions / Database
   

Database

 
AnswerRe: Floating Point Numbers Stored as Text with Integration Services Pin
Eddy Vluggen19-Jan-10 11:15
professionalEddy Vluggen19-Jan-10 11:15 
QuestionSQL Application - stuck on the way I should update my Table Pin
ps0f0r18-Jan-10 22:24
ps0f0r18-Jan-10 22:24 
AnswerRe: SQL Application - stuck on the way I should update my Table Pin
Mycroft Holmes19-Jan-10 10:39
professionalMycroft Holmes19-Jan-10 10:39 
QuestionQuestion about simple pattern recognition (hopefully the solution is simple too...) Pin
James Shao17-Jan-10 22:24
James Shao17-Jan-10 22:24 
AnswerRe: Question about simple pattern recognition (hopefully the solution is simple too...) Pin
Mycroft Holmes18-Jan-10 11:10
professionalMycroft Holmes18-Jan-10 11:10 
GeneralRe: Question about simple pattern recognition (hopefully the solution is simple too...) Pin
Luc Pattyn18-Jan-10 11:47
sitebuilderLuc Pattyn18-Jan-10 11:47 
GeneralRe: Question about simple pattern recognition (hopefully the solution is simple too...) Pin
James Shao18-Jan-10 12:43
James Shao18-Jan-10 12:43 
AnswerRe: Question about simple pattern recognition (hopefully the solution is simple too...) Pin
i.j.russell18-Jan-10 11:48
i.j.russell18-Jan-10 11:48 
You could do what you want using Sql.

USE tempdb
GO

CREATE TABLE #Data
(
	ObjectId INT NOT NULL,
	AttributeId TINYINT NOT NULL,
	Value TINYINT NOT NULL
)
GO

--Object     A     B     C     D     E     F
--a     6     9     1     9     9     3
--b     8     3     5     1     1     3
--c     7     0     8     3     5     8
--d     7     5     6     5     5     2
--e     8     9     2     2     8     0

INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (1, 1, 6);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (1, 2, 8);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (1, 3, 7);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (1, 4, 7);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (1, 5, 8);

INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (2, 1, 9);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (2, 2, 3);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (2, 3, 0);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (2, 4, 5);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (2, 5, 9);

INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (3, 1, 1);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (3, 2, 5);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (3, 3, 8);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (3, 4, 6);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (3, 5, 2);

INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (4, 1, 9);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (4, 2, 1);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (4, 3, 3);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (4, 4, 5);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (4, 5, 2);

INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (5, 1, 9);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (5, 2, 1);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (5, 3, 5);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (5, 4, 5);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (5, 5, 8);

INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (6, 1, 3);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (6, 2, 3);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (6, 3, 8);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (6, 4, 2);
INSERT INTO #Data (ObjectId, AttributeId, Value) VALUES (6, 5, 0);
GO

SELECT SourceId, 
	MatchId,
	COUNT(*) AS TotalMatches
FROM
(
	SELECT d1.ObjectId AS SourceId, 
		d2.ObjectId AS MatchId
	FROM #Data d1
	INNER JOIN #Data d2 
		ON d2.ObjectId > d1.ObjectId
	WHERE d2.AttributeId = d1.AttributeId
	AND d2.Value = d1.Value 
) t
GROUP BY SourceId, MatchId
ORDER BY COUNT(*) DESC
GO

DROP TABLE #Data
GO

GeneralRe: Question about simple pattern recognition (hopefully the solution is simple too...) Pin
James Shao18-Jan-10 22:00
James Shao18-Jan-10 22:00 
GeneralRe: Question about simple pattern recognition (hopefully the solution is simple too...) Pin
i.j.russell18-Jan-10 23:38
i.j.russell18-Jan-10 23:38 
QuestionHow to Import many excel Files to sql server 2005? Pin
caiguosen17-Jan-10 3:31
caiguosen17-Jan-10 3:31 
AnswerRe: How to Import many excel Files to sql server 2005? Pin
Eddy Vluggen17-Jan-10 6:13
professionalEddy Vluggen17-Jan-10 6:13 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
caiguosen20-Jan-10 23:49
caiguosen20-Jan-10 23:49 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
Eddy Vluggen21-Jan-10 0:11
professionalEddy Vluggen21-Jan-10 0:11 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
caiguosen21-Jan-10 0:58
caiguosen21-Jan-10 0:58 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
Eddy Vluggen21-Jan-10 1:25
professionalEddy Vluggen21-Jan-10 1:25 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
caiguosen23-Jan-10 21:50
caiguosen23-Jan-10 21:50 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
Eddy Vluggen24-Jan-10 1:47
professionalEddy Vluggen24-Jan-10 1:47 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
caiguosen24-Jan-10 2:05
caiguosen24-Jan-10 2:05 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
Eddy Vluggen24-Jan-10 4:54
professionalEddy Vluggen24-Jan-10 4:54 
GeneralRe: How to Import many excel Files to sql server 2005? Pin
caiguosen24-Jan-10 16:23
caiguosen24-Jan-10 16:23 
Questionfixing table for looping through checkboxlist. Pin
macupryk16-Jan-10 12:18
macupryk16-Jan-10 12:18 
GeneralThe Secret $5680 in 24 Hour Strategy Pin
mFarooq7215-Jan-10 14:38
mFarooq7215-Jan-10 14:38 
GeneralRe: The Secret $5680 in 24 Hour Strategy Pin
Mycroft Holmes15-Jan-10 16:27
professionalMycroft Holmes15-Jan-10 16:27 
QuestionUsing table Variables Create outside a UDF inside a UDF Pin
Vimalsoft(Pty) Ltd15-Jan-10 1:08
professionalVimalsoft(Pty) Ltd15-Jan-10 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.