Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What I Have so far: CREATE FUNCTION fnInsPlans (@PlanName varchar(50)) RETURNS int BEGIN RETURN (SELECT COUNT(*) FROM EmpData WHERE TermDate IS NOT NULL (SELECT BenPlanID

What I Have so far: CREATE FUNCTION fnInsPlans (@PlanName varchar(50)) RETURNS int BEGIN RETURN (SELECT COUNT(*) FROM EmpData WHERE TermDate IS NOT NULL (SELECT BenPlanID FROM Benefits WHERE PlanName = @PlanName)) END; 

Instructions: The return portion of the select should include one column- a count of the records in the EmpData table and should filter the results so only active employees (not terminated) are counted. The where should also utilize a subquery in the where to find the BenPlanID number based on the input parameter (@PlanName).

I am struggling with getting my subquery to work, currently it just says "Select statements included within a function cannot return data to a client". What would be the correct way to put this in order for it to work properly?

This is for SQL Server NOT MySQL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Management

Authors: Gareth Jones, Jennifer George

9th Edition

0077718372, 978-0077718374

More Books

Students also viewed these Databases questions

Question

What do we know about police officers as eyewitnesses?

Answered: 1 week ago

Question

What do we know about elderly people as eyewitnesses?

Answered: 1 week ago