By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

How do I write a query to list all active employees plus "(All Employees)" row

P: 3
if I have a table with the following fields

TblEmployee

EmployeeID
Employeename
JobDescription
DeptID
Active
Oct 23 '12 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,366
To limit the query to active, use the WHERE clause to filter for the active. I have no idea what you mean by the all employees row. That makes no sense unless you're doing an aggregate query but you haven't indicated that is the case.
Oct 23 '12 #2

NeoPa
Expert Mod 15k+
P: 31,489
I'm guessing (The question is very poor and lacks a clear indication of what you want.) you're looking for a query that lists the items from the table as well as a special line to reflect all records. In that case you can use the UNION operator in SQL.
Oct 23 '12 #3

P: 3
Thank you for your responses. Actually this was part of a SQL test that I had to take as a part of a job interview. I answered the question using a where clause but I was not sure whether I was right and needed professional advice.
I agree that the question is poorly phrased and it is probably intentionally set this way to confuse the test taker (that is me) LOL
Well, I hope that my results will be good enough to land me the job as I really need one.
Thanks again.
Oct 24 '12 #4

NeoPa
Expert Mod 15k+
P: 31,489
Aha :-D

The rules for questions on here and those for a job interview (where there is none) are markedly different. If you're setting a test then you're pretty well in charge really.

Unfortunately for you (I'm sorry to say), the the question was about adding an extra line which doesn't initially exist rather than filtering out unwanted items. As such your answer would probably not be seen as adequate.
Oct 24 '12 #5

P: 3
Neopa,
I agree with you. I will find out (hopefully after I get the job) who set such poor questions but for now I have to do all I can to secure the job.
Oct 25 '12 #6

NeoPa
Expert Mod 15k+
P: 31,489
I'm not sure you quite understand what I was saying. The question isn't a problem for a job interview. They, quite rightly, make their own rules for that. I'm sorry to say that I don't believe your answer was what they were looking for (It breaks our forum rules, but that's not something we'll lose sleep over now we understand what you were trying to ask for). Hopefully though, if a similar question comes up again, you'll be able to provide what they are looking for as I gave that in my first response.
Oct 25 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.