A Little Fool

Fool For Free.

博客园 首页 新随笔 联系 订阅 管理
USE XSCJ
GO


CREATE PROCEDURE dbo.proc_bgnum  @xbh VARCHAR(8) AS
DECLARE @nBoys INT
DECLARE @nGirls  INT

IF   object_id('tempdb..#tmpNewTable') IS NOT NULL 
        DROP TABLE #tmpNewTable

SELECT 学号, 性别 INTO #tmpNewTable FROM 学生基本信息表 a, 班级表 b
WHERE a.班级编号 = b.班级编号 AND 系部编号 = @xbh

SELECT @nBoys = COUNT(*) FROM #tmpNewTable
WHERE 性别 = '男'
SELECT @nGirls = COUNT(*) FROM #tmpNewTable
WHERE 性别 = '女'

SELECT @nBoys 男生人数, @nGirls 女生人数
GO

EXEC proc_bgnum '01'

文章来源:http://henrya2.blog.163.com/blog/static/754514192008102891428803
posted on 2008-11-28 21:14  HenryRead  阅读(789)  评论(0编辑  收藏  举报