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 |
nhaas
Yak Posting Veteran
90 Posts |
Posted - 2011-08-19 : 12:53:59
|
I want to save a monthly Inventory but am not sure of the best way. Am I on the right track with this query?////v_num number;beginSelect [type],[ORG], Count(type)as TypeCount FROM [Tesisdev].[dbo].[VOIPNumbers] group by [ORG],[TYPE] ORDER BY ORG;if v_num = 0 theninsert into MonthInventory values (val1,val2,val3,val4);commit;elseraise_exception;end if;end;/// |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-19 : 13:01:42
|
sorry didnt get thatwhere did u get v_num etc from?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
nhaas
Yak Posting Veteran
90 Posts |
Posted - 2011-08-19 : 13:10:44
|
Just trying to think of a way to put what the Select statement returns into the MonthlyInventory table. Just a guess at this point |
|
|
nhaas
Yak Posting Veteran
90 Posts |
Posted - 2011-08-19 : 13:26:05
|
I got it, I hope that this will be correct;INSERT INTO [Tesisdev].[dbo].[VOIPMonthlyInventory] ([TYPE],[ORG],[Quantity]) Select [type],[ORG], Count(type)as TypeCount FROM [Tesisdev].[dbo].[VOIPNumbers] group by [ORG],[TYPE] ORDER BY ORG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-20 : 02:00:28
|
yep this looks fine.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|