select - Need Simple Query in Sql server -


my criteria:

i have distributor (parent table), has many retailer (child table). need last joined retailer name.

i.e

distributor list  |  total no. retailer    |     last joined retailer name 

my query :

select distname,          count(retailername) totalretailer,          max(retailername) lastposted,          max(lastjoinretail) lastjoindate  distributor d   right outer join retailer r on d.distno = r.retailno                              , r.status = 0                               , d.status = 0 group distname..... 

i not getting last joined "retailer name"?.

select [distributor_name]     , [total_no._retailer]     , [last date]     , (select name tbl_retailer [last date] = createddate) [last joined retailer name] (     select         d.name 'distributor_name'         ,count(r.name) 'total_no._retailer'         ,max(r.createddate) 'last date'     tbl_distributor d     inner join tbl_retailer r on d.id = r.distributorid     group d.name ) t order [distributor_name] 

possible mismatch column names


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -