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.
| Author |
Topic |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2002-02-22 : 08:30:38
|
| Even though the design is messy can this be done?I have a table with mins & mins2 and I want to add the two fields from multiple records. (I know it should be related by taskid in another tablebut I didn't have that luxury, yet)--create table #current (taskid int, oid int, responsible varchar(20), responsible2 varchar(20), mins int, mins2 int, billable int, billable2 int)insert #current values(1,100, 'Melinda', NULL, 60, 0, 1,0)insert #current values(1,100, NULL, 'Christie' , 0,3, 0,1)select sum(mins) as total from #current where billable = 1 group by taskidunion allselect sum(mins2)as total from #current where billable2= 1 group by taskidcan we the total minutes billed. In this example it would be 63 but listedin one row for a rs return.thanksslow down to move faster... |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-02-22 : 08:45:52
|
| Why not:SELECT Sum(mins + mins2) AS total FROM #current WHERE billable=1 OR billable2=1 GROUP BY taskid |
 |
|
|
|
|
|
|
|