UNION ALL
UseMyDBSELECT 'Greater than' asScopeCount(*) asnumber fromStudentwhereAge>= -Union All SELECT 'less than' asScope,Count(*) asnumber fromStudentwhereAge< -
Select sum( Case whenAge>= - andAge< + Then 1 Else 0 End) asf_cnt,sum( Case whenAge>= + andAge< - Then 1 Else 0 End) ass_cnt,sum( Case whenAge>= - Then 1 Else 0 End) asE_cnt fromStudentSelect sum( Case whenAge>= - andAge< + ThenAgeElse 0 End) asf_cnt,sum( Case whenAge>= + andAge< - ThenAgeElse 0 End) ass_cnt,sum( Case whenAge>= - ThenAgeElse 0 End) asE_cnt fromStudent
/*time limit: 2010-03-01 to 2010-05-01 customer code customer name period sales quantity (before 2010-03-01 sales) beginning Sales Amount (2010-03-01 Sales Amount) Sales volume for the period sales amount ( Sales before 2010-05-01) final sales amount (sales before 2010-05-01)*/ UseBserp_zb;SelectKehu. Khdm asCustomer code, Kehu. Khmc asCustomer Name,SUM( Case whenRQ< '2013-05-01' ThenSlElse 0 End) assales volume at the beginning of the period,SUM( Case whenRQ< '2013-05-01' ThenSl*DjElse 0 End) asSales Amount at the beginning of the period,SUM( Case whenRQbetween '2013-05-01' and '2013-07-01' ThenSlElse 0 End) asnumber of sales in this issue,SUM( Case whenRQbetween '2013-05-01' and '2013-07-01' ThenSl*DjElse 0 End) asSales amount in the current period,SUM( Case whenRQ< '2013-07-01' ThenSlElse 0 End) asFinal sales quantity,SUM( Case whenRQ<'2013-07-01' ThenSl*DjElse 0 End) asFinal Sales Amount fromVW_PFXHMX, Kehu,shangpinwhereVW_PFXHMX.DM1=Kehu. Khdm andVw_pfxhmx. SPDM=Shangpin. SPDMGroup byKehu. KHDM, Kehu. KHMC;
/*Customer order Execution analysis customer code customer name planned order number VW_PFJRDMX. SL Termination Order Number Vw_pfjrdmx.sl_3 number of active orders (number of orders-deactivated) number of shipments vw_pfxhmx. SL Arrears (Number of shipments-number of active orders)*/ SelectKehu. Khdm asCustomer code, Kehu. Khmc asCustomer Name,sum(VW_PFJRDMX.SL) asNumber of planned orders,sum(Sl_3) asNumber of termination orders,SUM(VW_PFJRDMX.SL-Sl_3) asnumber of valid orders,sum(VW_PFXHMX.SL) asNumber of shipments,sum(VW_PFXHMX.SL-(VW_PFJRDMX.SL-Sl_3)) asNumber of goods owed fromVW_PFJRDMX,VW_PFXHMX, KehuwhereKehu. Khdm=VW_PFJRDMX. DM1 andVW_PFJRDMX. SPDM=Vw_pfxhmx. SPDMGroup byKehu. KHDM, Kehu. KHMC;
/*Wholesale Comparison Statistics current period limit: 2010-05-01 to 2010-05-31 Previous period time limit: 2010-04-01 to 2010-04-30 Commodity code pre-shipment amount The amount of goods shipped in the current issue volume increase: ( Current issue amount-pre-shipment amount) growth rate: (current issue amount-pre-shipment amount) *100/Pre- shipment amount*/SelectShangpin. SPDM ascommodity code, Shangpin. Spmc asProduct Name,SUM( Case whenRQbetween '2013-04-01' and '2013-04-30' ThenVw_pfxhmx.slElse 0 End) asPre-shipment number,SUM( Case whenRQbetween '2013-04-01' and '2013-04-30' ThenVw_pfxhmx.sl*DjElse 0 End) asPre-shipment amount,SUM( Case whenRQbetween '2013-05-01' and '2013-05-31' ThenVw_pfxhmx.slElse 0 End) asnumber of shipments in this issue,SUM( Case whenRQbetween '2013-05-01' and '2013-05-31' ThenVw_pfxhmx.sl*DjElse 0 End) asCurrent Issue Amount fromVW_PFXHMX, ShangpinwhereVW_PFXHMX.SPDM=Shangpin. SPDMGroup byShangpin. Spdm,shangpin. SPMC;
Union of SQL queries, case, group