hi
I have 2 table in my database
Classification table
Id
|
classification
|
behcode
|
Totalproduct
|
1
|
electric
|
1111
|
|
2
|
Furniture
|
1111
|
|
3
|
Cloth
|
2222
|
|
Users tabel
Id
|
name
|
classification
|
behcode
|
1
|
iron
|
Electric
|
1111
|
2
|
Vaccum cleaner
|
Electric
|
1111
|
3
|
Sofa
|
Furniture
|
1111
|
4
|
Scarf
|
Cloth
|
222
|
I want write SP that count Totalproduct for classification table from users table
I did it for one table
Id
|
name
|
classification
|
behcode
|
Totalproduct
|
1
|
iron
|
Electric
|
1111
|
|
2
|
Vaccum cleaner
|
Electric
|
1111
|
|
3
|
Sofa
|
Furniture
|
1111
|
|
4
|
Scarf
|
Cloth
|
222
|
|
SP
USE [behtop]
GO
/****** Object: StoredProcedure [dbo].[classmanager] Script Date: 06/21/2012 15:29:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[classmanager]
as
begin
SET NOCOUNT ON
select distinct classification,COUNT(Classification) Totalproduct
from House_p
where BehCode=1111
group by classification
end
Now I want do it for 2 table count from userstable and insert in Classification table
best regards