我试图计算平均值,最小值,最大值,总数,但我得到错误的结果。选择结果的平均值(),min(),max(),toatl(),count()
SELECT t0.brandID, t0.brandName, t0.cdt, t0.udt, t0.brandstatus, t0.AddedBy ,
AVG(t0.brandID) AS brandID_AVERAGE,
min(t0.brandid) as branid_min,
MAX(t0.brandid) as brandid_max,
COUNT(t0.brandid) as brandid_count
FROM brands t0
Where t0. brandID=null OR t0. brandName='khasim'
group by t0.brandID,t0.brandName,t0.cdt,t0.udt,t0.brandstatus,t0.AddedBy
select AVG(CAST (brandID AS bigint)) AS brandID_AVERAGE,
min(CAST (brandID AS bigint)) as branid_min,
MAX(CAST (brandID AS bigint)) as brandid_max,
COUNT(CAST (brandID AS bigint)) as brandid_count from
(SELECT t0.brandID, t0.brandName, t0.cdt, t0.udt, t0.brandstatus, t0.AddedBy
FROM brands t0
Where t0. brandID=null OR t0. brandName='budwieser'
group by t0.brandID,t0.brandName,t0.cdt,t0.udt,t0.brandstatus,t0.AddedBy) temptable
我已经改变了我的查询,选择平均等,为的选择结果现在 我得到我所期望的,但我想显示 一个表怎么办所有选定列。
将t0.brandid = null替换为null – TheGameiswar
@TheGameiswar,确保它是't0.brandId为null'。 'is'和'null'之间的空间很重要。 – SlimsGhost
是的,那是类型,我编辑它长回 – TheGameiswar