Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Help with a difficult query

Author  Topic 

raxbat
Yak Posting Veteran

52 Posts

Posted - 2008-02-21 : 01:47:36
Hello friends!
Help me please to construct sucha a query:

I have a list of processes, each of them has a value! I need to compere each process with every anather process.

Example:
Process Value
1 0.1
2 0.105
3 0.09
4 0.09

I need to get the following result of a query:

Process1 Process2 Value_delta
1 2 0.05
1 3 0.01
1 4 0.01
2 3 0.015
....


Thank You!

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-21 : 04:25:11
how is value delta calculated?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-21 : 06:28:07
[code]DECLARE @Sample TABLE (Process TINYINT, Value SMALLMONEY)

INSERT @Sample
SELECT 1, 0.100 UNION ALL
SELECT 2, 0.105 UNION ALL
SELECT 3, 0.090 UNION ALL
SELECT 4, 0.090

SELECT s1.Process,
s2.Process,
ABS(s1.Value - s2.Value) AS Delta
FROM @Sample AS s1
INNER JOIN @Sample AS s2 ON s2.Process > s1.Process[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -