1
我很困惑,爲什麼我的結果在Project_ID中顯示爲null。我看了一下下面的帖子,然後嘗試了inner join
,但結果是徒勞的,和left join
一樣。我只有兩個不同的Project_ID。出於某種奇怪的原因,Name
再次被陳述,其中Count
從以前的列表中添加。爲什麼它這樣做,我該如何解決這個問題?請提供您的建議。爲什麼我的SQL語法顯示爲空?
Why does my SQL query return rows with NULL? It should never return rows with NULL
結果:
Name Count Maximum Hours Worked Maximum Salary Project_ID
Hulk Hogan 157 3,500 $432,995.00 LFC
Hulk Hogan 43 3,499 $550,000.00 PCR
Hulk Hogan 200 3,500 $550,000.00 (null)
Andre the Giant 42 5,300 $870,000.00 PCR
Andre the Giant 42 5,300 $870,000.00 (null)
Bret Hart 5 3,675 $512,000.00 LFC
Bret Hart 10 4,193 $716,510.00 PCR
Bret Hart 15 4,193 $716,510.00 (null)
Winnie the Pooh 561 5,600 $929,654.00 PCR
Winnie the Pooh 561 5,600 $929,654.00 (null)
1000 5,600 $929,654.00 (null)
這是從'rollup' - 這是你的應用在聚集和Name''Project_Id'的'每組作爲總結。因此,你可以從工作時間和薪水中得到總數「count」和「max」記錄。最終的記錄是整個集合的總結。 – Siyual
如果我刪除'rollup',它不會爲我提供每個列的總數。然後,將總計添加到此語句的所有列的最可行方法是什麼? –
不幸的是,我對postgres的語法知之甚少,無法回答如何過濾掉子分組。 – Siyual