- 论坛徽章:
- 0
|
本帖最后由 cenalulu 于 2012-06-19 11:34 编辑
Mysql Server 5.5- select TypeOfBusiness, depOrProfitName, Month,BudgetAccount,MonthBudget from
- (select TypeOfBusiness,depOrProfitName,Month,StatementsSubjects,BudgetAccount,SUM(MonthBudget) as MonthBudget from TotalBudgetOfdepOrProfitName_Adjust_souce where BudgetAccount='奖金' group by TypeOfBusiness,depOrProfitName,Month,StatementsSubjects)
- as a where BudgetAccount='奖金' order by TypeOfBusiness , depOrProfitName ;;
复制代码 这样可以查出记录,但是去掉第1个 where BudgetAccount='奖金' 反而查不到记录,百思不得其解?谁能解释下么,下面是去掉条件后查不到记录的sql。- select TypeOfBusiness, depOrProfitName, Month,BudgetAccount,MonthBudget from
- (select TypeOfBusiness,depOrProfitName,Month,StatementsSubjects,BudgetAccount,SUM(MonthBudget) as MonthBudget from TotalBudgetOfdepOrProfitName_Adjust_souce group by TypeOfBusiness,depOrProfitName,Month,StatementsSubjects)
- as a where BudgetAccount='奖金' order by TypeOfBusiness , depOrProfitName ;;
复制代码 按理说,去掉限制条件,查询到的记录只可能更多,为什么反而更少呢?
|
|