我試圖計算平均值,最小值,最大值,總數,但我得到錯誤的結果。選擇結果的平均值(),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