SQL Question - Joins - TechRepublic
General discussion
May 21, 2004 at 07:04 AM
jafa

SQL Question – Joins

by jafa . Updated 21 years, 12 months ago

Hello all

I need to perform a query on two tables in SQL Server 2000.

I need to pull everything from table2 with the values from table one, if the type matches use that value, otherwise if the type dosen’t match I need to use the value where the type is null.

Example:

Table1 Table2
Style Type Vaule Style Type
—————- ———–
a 1 a 5
a 1 .9 a 1
a 2 .8 a 3
b 1.1 a 2
b 1 1 b 4
c 1.2 c 4
c 3
c 1

Desired Output
Style Type Value
—————–
a 5 1
a 1 .9
a 3 1
a 2 .8
b 4 1.1

Any ideas?

Thanks

This discussion is locked

All Comments