× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



With the latest upgrade of our hospital database, a new twist was added. For
users to be authorized to a function, they also need authorization to a second
function.

What I have done thus far is create a simple query that groups by security code
and selects the security records for the two functions, Made a 15 page report
that I have to go through. Not a big deal. But, I am wondering if SQL can do
this better, and I can learn an alternate method in the event this happens
again.

A simple attempt at a SELECT that accomplishes what my query did might be:

SELECT QSSEC2, QSFN01 FROM BSYSQSP2
WHERE QSFN01 = 'BPB101' or QSFN01 = 'BPB400'
GROUP BY QSSEC2
ORDER BY QSFN01

I'm not sure that is correct, but I am confidant that I can find any error
rather quickly in an actual SQL session. The file is keyed on QSSEC2, and
there can be a number of records for a given security code (QSSEC2).

I have two questions:

1) Based on what I have presented, is it possible to create a query that only
shows QSSEC2 when there is a record containing BPB101 but not one (for the same
security code) that contains BPB400?

2) If the answer to the first question is yes, can an INSERT be created that
would add a security record containing BPB400 when that was needed?

My first reaction is to just go through my report and do it manually. This
isn't something I want to trash by me guessing at the process, I could see an
RPG program that would loop through a logical keyed on QSSEC2. When a BPB101
record was found, write a BPB400 record when the group changes.

I started thinking about an SQL statement to answer the first question. My
attempt did not make a lot of sense. I have seen references to using a CTE in
other problems. Would that be beneficial here?

Just wanting to learn an alternate method, if it exists.

John McKee


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.