Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION PlayerStatistic(@id int)
- RETURNS @rtnTable TABLE
- (
- -- columns returned by the function
- home_team Varchar(30), guest_team Varchar(30),team_name Varchar(30),start_time Datetime,ganeral_game_time_goal_scored int default NULL,overtime_time_goal_scored int default NULL,after_total_time_bullit_scored int default NULL,
- home_team_score int default NULL,overtime_home_team_score int default NULL,bullits_home_team_score int default NULL,guest_team_score int default NULL,overtime_guest_team_score int default NULL,bullits_guest_team_score int default NULL
- )
- AS
- BEGIN
- DECLARE @Table table (home_team Varchar(30), guest_team Varchar(30), team_name Varchar(30),start_time Datetime, ganeral_game_time_goal_scored int,overtime_time_goal_scored int ,after_total_time_bullit_scored int,
- home_team_score int,overtime_home_team_score int,bullits_home_team_score int,guest_team_score int,overtime_guest_team_score int,bullits_guest_team_score int )
- insert into @Table
- select (select Team.team_name from Team where Team.team_id = ga.home_team_id), (select Team.team_name from Team where Team.team_id = ga.guest_team_id), t.team_name,ga.start_time, pl.ganeral_game_time_goal_scored,pl.overtime_goal_scored, pl.after_total_time_bullit_scored,
- ga.home_team_score,ga.overtime_home_team_score,bullits_home_team_score, ga.guest_team_score, ga.overtime_guest_team_score,ga.bullits_guest_team_score
- from PlayerGameApplication pl
- Join Game ga on pl.game_id = ga.game_id
- Join Players player on player.player_id = pl.player_id
- Join Team t on t.team_id = pl.team_id
- where pl.player_id = @id
- --This select returns data
- insert into @rtnTable
- SELECT * FROM @Table
- return
- END;
Add Comment
Please, Sign In to add comment