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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to get ?

Author  Topic 

subrata.bauri
Starting Member

17 Posts

Posted - 2011-06-30 : 06:35:06
[code]update #temp
set #temp.Quantity_mc = a.Total
from #temp Inner join
(
select psp_item_no,psp_item_var,sum(psp_qty_prpnl) as Total
from pmddb..pmd_mpsp_ps_postn pmd
WHERE NOT EXISTS (SELECT * From common..ims_variant_master ims,pmddb..pmd_mpsp_ps_postn pmd2
where description like 'Optional%' and
ims.stock_no= pmd2.psp_item_no and
pmd2.psp_ps_no = pmd.psp_ps_no and
pmd2.psp_io_flag = 'o'
)

group by psp_item_no,psp_item_var
) as a
on #temp.item_code = a.psp_item_no AND
#temp.variant_code=a.psp_item_var [/code]

This is my code where I want update my Temp Table.

Temp Table Definition :
[code]
create table #temp
(
item_code varchar(50) ,
variant_code varchar(10),
item_desc varchar(200),
uom varchar(10),
Quantity_mc numeric(28,3),
Available_Quantity numeric(28,3),
no_of_mechine numeric(28,3),
reminder numeric(28,3),
bom_item_code varchar(50),
bom_variant_code varchar(10),
bom_item_desc varchar(200),
bom_uom varchar(10),
) [/code]
The set of Result I have received by the code
group by psp_item_no,psp_item_var [/code] is


subrata.bauri
Starting Member

17 Posts

Posted - 2011-06-30 : 06:42:54
[code]psp_ps_no psp_item_no psp_item_var psp_io_flag
7 DRR07DFAB0034 ## I
15 DRR07DFAB0034 ## I[/code]
But I only want the psp_ps_no =7 row, because this row has only relation with the Input psp_ps_no =16.
The relation I've to show in the Excel Sheet herewith :

[url]http://www.flickr.com/photos/64644710@N07/5886985877/in/photostream#/photos/64644710@N07/5886985877/in/photostream/lightbox/[/url]
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-30 : 07:20:49
You only want to rows that have a relationship with psp_ps_no =16?
How is the relationship modelled?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -