This query handles the case in which one method (either A or B) is missing for an ID value. It does that by using SELECT DISTINCT and selecting the Hours(A) value and the Hours(B) value for each column for the unique ID. If a value is missing for either A or B, then the result is NULL. If you want something other than NULL to display, use the ISNULL() function and CAST statement. See example of that at the bottom of this solution.
select distinct t1.id as ID,
(Select hours from table_1 As T3 where T3.id=t1.id and T3.method='A') as [Hours(A)],
(Select hours from table_1 As T4 where T4.id=t1.id and T4.method='B') as [Hours(B)]
from Table_1 as T1
Results
Quote:
ID Hours(A) Hours(A)
1 2.50 5.00
2 0.50 1.50
3 3.25 NULL
select distinct t1.id as ID,
ISNULL(CAST((Select hours from table_1 As T3 where T3.id=t1.id and T3.method='A') as varchar(6)),'N/A') as [Hours(A)],
ISNULL(CAST((Select hours from table_1 As T4 where T4.id=t1.id and T4.method='B') as varchar(6)),'N/A') as [Hours(A)]
from Table_1 as T1
Results
Quote:
ID Hours(A) Hours(A)
1 2.50 5.00
2 0.50 1.50
3 3.25 N/A
Tested: SQL Server Express 2012
______________________________________________________________________________________________
SQL Create Table statement
CREATE TABLE [dbo].[Table_1](
[ID] [int] NULL,
[Hours] [numeric](8, 2) NULL,
[Method] [nchar](1) NULL
) ON [PRIMARY]
SQL Insert statements to create test data
insert into table_1 (id,hours,method) values(1,2.5,'A');
insert into table_1 (id,hours,method) values(1,5.0,'B');
insert into table_1 (id,hours,method) values(2,0.5,'A');
insert into table_1 (id,hours,method) values(2,1.5,'B');
insert into table_1 (id,hours,method) values(3,3.25,'A');