c# - rank records according to vendors having most sales(Quantity*Price) -
mine event management related website.. on admin side need following : vendorname
, vendorphoto
, vendorphone
, vendoremail
, servicetype(serviceid)
based on rankin of sales(quantity
*price
) displayed in eventitem
table , i.e. :
a vendor a(serviceid : 1 , service.name:florist) has couple of vendoritems in table vendoritem
(i.e. product table) , other vendors have entries in table vendoritem
. when user registers event choose quantity
, product(i.e. vendoritem
) of vendor.
then query should check amongst vendors of particular type(e.g. : florist,etc) , has sales(top 3)/
this query have tried far, not able required results , confused in how calculate value quantity*product
?
select top (3) tblvendor.vendorid, tblvendor.name, tblvendor.email, tblvendor.phone, tblvendor.address, tblvendor.username, tblvendor.password, tblvendor.serviceid, tblvendor.isactive, tblvendor.photo, tbleventitem.quantity, tbleventitem.price tbleventitem cross join tblvendor inner join tbleventservice on tbleventservice.vendorid = tblvendor.vendorid (tbleventservice.vendorid = 7) order isnull(tbleventitem.quantity, 0) * isnull(tbleventitem.price, 0) desc
select top 3 tbleventitem.quantity*tbleventitem.price 'sales', tbleventitem.vendoritemid, tblvendor.name, tblvendor.email, tblvendor.phone, tblvendor.photo tbleventservice inner join tbleventitem on tbleventservice.eventserviceid = tbleventitem.eventserviceid inner join tblvendor on tbleventservice.vendorid = tblvendor.vendorid tbleventservice.serviceid = @s_id order 'sales' desc
this query magic .
here make column multiplying 2 columns : tbleventitem.quantity*tbleventitem.price
, taking column sales
.
other selections basic inner joins
per requirements in select
query .
the order 'sales' desc
give top 3 vendors max sales!
Comments
Post a Comment