我有这样的疑问: public static function totalByAgent(int $agentId)
{
return PropertyListing::select(
DB::raw('SUM(property_listing.rental) as rental'),
DB::raw('SUM(property_listing.sale) as sale'),
'property_category.name as category_name',
'
希望你一切都好 我有两个模型 class Property(models.Model):
....
city = models.ForeignKey(City,on_delete=models.CASCADE)
class City(models.Model):
img = models.ImageField(upload_to='city/img',blank=True,null=True)
name = models.CharField(max_length=200,unique=True) 我想要3个拥有最多房产的城市意味着我想要拥有
背景
被打字稿卡住了。我理解这一声明:
let varName:number; //null,string,..declare simple variables.
let arrName:string[] // or arrName:number[]. etc
显然,这是用于对象:
//knowing type of the property
let obj: {property:string, also:number[]} = {property:'hello', also:[1,2,3]}
//now knowing the type of the property
因此,我必须编写一个查询,它将显示城市、平均要价和房产总数,以及那些拥有超过100套房产的城市的总数。我有代码:
SELECT Property.City, '$' + CONVERT(NVARCHAR, AVG(Listing.AskingPrice),1) AS 'Avg. Asking Price', COUNT(Property.PropertyID) AS 'No. of Properties'
FROM Property
INNER JOIN Listing
ON Property.PropertyID = Listing.Prop