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
 General SQL Server Forums
 New to SQL Server Programming
 add a field to table

Author  Topic 

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-08-25 : 04:08:03
select t1.*,t2.Product_Name from
(
select mobid,
max(case when seq=1 then merchant else null end) as min_merchant,
max(case when seq=1 then price else null end) as min_price,
max(case when bseq=1 then merchant else null end) as max_merchant,
max(case when bseq=1 then price else null end) as max_price
from
(
select row_number() over (partition by mobid order by price) as seq,row_number() over (partition by mobid order by price desc) as bseq,mobid, merchant,price
from tbl_merchant
)t
where (seq=1 or bseq=1) and mobid in(select MOBID from tbl_product where Client_Name='wilson')


group by mobid
) as t1 INNER JOIN tbl_product as t2 on t2.mobid=t1.mobid

In the above query i need to add my_Price field where
my_price is where my name matches for that product

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-25 : 04:59:45
Duplicate question. Please continue here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=149262


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-25 : 09:22:08
why are you opening so many threads for same question?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-25 : 09:29:45
I think OP is hyperstressed. Read http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=149262 and get the feeling of interaction.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -