Scenario
Each Online User has a set of skills assigned to him, Based on their skills they need to be mapped to a specific team, For which I need to check all the skills and if a certain set of skills are present assign him a team.
My Implementation till now
I used a CASE statement to check skills and if they match exactly give the name to that entry.
Problem I am facing
If the user is assigned more skills to help other teams then these conditions fails and it goes to ELSE condition.
So I was thinking if it is possible to include contains logic that will check if certain skills are present for the user then assign him a team according to that, And it is also possible a User is part of two teams, So if two skill set matches then two teams should be assigned to him, In CASE statement it is
not possible to achieve this.
I have gone through REGEXP, but I guess that also will not help.
Let me know if more clarity is needed.
Related
So, this is probably simple. I need to find a way to check whether a member of a scheme has renewed their membership or let it expire, I need to generate a simple list of those whom have not renewed.... There are complicating factors however, in that I cant use Excel, and it can only be a single step to Crystal reports (though I have solved the issue in Excel using a simple Countifs and if Formula)
Now for the problem.
The membership has specified Start/End Dates in separate columns in the table. It is easy to see whether this, in a row basis has expired. The issue is that if they have renewed, this is logged as a separate table entry linked by a Individual reference to the member. There are also multiple Qualifications I also need to test against.
So, whilst I can test the expiration date, the question is how can I test against the rest of the data, based on whether the Individual Reference and Qualification name and then check whether this is "Current". Doing this would enable me to therefore test whether the Membership has therefore been renewed, or not, on an individual line.
Any advice on methods would be appreciated.
Without knowing what data you have and making assumptions out the wazoo, try something along these lines
select distinct Member_id,
case
when exists (select 1
from members m2
where m2.member_id = m1.member_id
and (m2.expiry_date is null
or m2.expiry_date > '2018-01-25'))
then 'Active'
else 'Expired'
end as mem_status
from members m1
What the exists does is look and see if that member has an active status
Let me start by saying, I have scoured the web for help with this, tried figuring it out with a professor and used a Database Systems text book and have still not gotten this to work properly. I am attempting to finish this database as my final project for a DB management course that I'm taking, but it is also for real world use at work. My team at work currently creates access to a clinical system for end users. When we receive a request form it includes a "ServiceNow Position" (Column A) and a "ServiceNow Role" (Column B). My team has to then reference a spreadsheet, which I've attempted to attach, to find out what this correlates to in the clinical system (Column C). The row of the spreadsheet also dictates what, if any, user orgs (Column F) and user groups (column G) that the user account receives. I'm including a screenshot of the relationship between the tables prior to my modifications to the SQL statement, as once the outer joins are in place, the relationships don't illustrate.
The idea here is that I will always be given the ServiceNow role and position, it will always correlate to a row on the "Cerner_HNA_Positions" table. I will NOT necessarily always have User_Group or Organizations, though when I do have them, I may have up to 2 and 4 respectively.
My goal is to get a query that works properly, and then create a form on top of this so that who ever is working account creations can insert the ServiceNow Position and Role and have returned what the "Cerner_HNA_Positions.HNA_Position" is and any correlated User Groups and Organizations. The following is the closest SQL statement that I've gotten to function without a syntax error. However, this is returning every HNA_User_Group and HNA_Org, even though the row for HNA_Position that it returns does not have any HNA_User_Group's or Orgs assigned. I'm sure this is something to do with the fact that I've done a left join, but my goal in this was to ensure that I see the HNA_Position. Can anyone help me with this?
SELECT DISTINCT Cerner_HNA_Positions.HNA_Position,
Cerner_HNA_Positions.Like_User,
Cerner_HNA_Positions.Physician,
Cerner_HNA_Positions.Add_Resources,
Cerner_HNA_User_Groups.*,
Cerner_HNA_Organizations.*,
[Service Now Position Name].Service_Now_Position,
[ServiceNow Role].Service_Now_Role
FROM Cerner_HNA_User_Groups,
Cerner_HNA_Organizations,
[ServiceNow Role]
INNER JOIN ([Service Now Position Name]
INNER JOIN Cerner_HNA_Positions
ON [Service Now Position Name].Service_Now_Position_ID =
Cerner_HNA_Positions.Service_Now_Position_ID)
ON [ServiceNow Role].Service_Now_Role_ID =
Cerner_HNA_Positions.Service_Now_Role_ID
WHERE ((([Service Now Position Name].Service_Now_Position)="CIS - PowerChart")
AND (([ServiceNow Role].Service_Now_Role)="Resident"));
Spreadsheet referenced above: https://www.dropbox.com/s/1vreampypo17lcd/Positions_Roles%20Sheet.xlsx?dl=0
I am building a "Survey" type application. The user answers a set of questions with pre-vetted answers.
Question: Where do you live?
Answers: England, Finland, Spain, France, Monrovia
The answers in this case would be in a DropDownList.
Once the user has completed the basic responses (location, age, sex etc) I would like to be able to prevent them accessing the rest of the survey based on their answers.
So for example, if they live anywhere but England I want to direct them to a page which says "Thanks, but Monrovian's can't complete this survey". I need my filtering to be user configurable (Table based) and I need to be able to have ANDs and ORs.
So one filter being the user MUST earn 100k+ a year.
Another being they must either live in Spain, or be female AND like model trains - "100k+ && (Spain || (Female && Trains))"
I would usually use Enums and bitmasking for this, but as my country list is 200+ items long, I can't think of a sensible way to store the filtering.
Hopefully I have made some sense and someone has a decent solution :)
I don't know if I can answer your question completely, but I'll try...
So, we have a bunch of Views that are only visible to the user if she previously chose some answers, like, she will see view#3 if she is older that 30, and view#4 if she is younger than 30 AND from China, and view#5 if she is older than 40 AND from Spain OR Italy, and so on...I want also to introduce the notion of **step**, and for each step we could have 1, 2, or more corresponding views. Each view should have a set of rules (like the ones above) that define if it is displayed or not.
How to create these rules? These rules could be simple instances of a Filter class/interface that, when asked, should return true/false. Like this:
interface Filter {
boolean apply();
}
Then you can create Filters like 'older than 30', 'from Spain', whatever. Remember that each view is configured with a set of rules (Filters) so it can answer yes/no if asked if it can display itself.
Next, how to apply these filters?
We could have a controller object that only knows about **steps** (each step can have one or more corresponding views, as I said), and, after the user pressed **next** at the current step, it should collect the answers and apply them against the rules attached to each view. Like, take the answers from step one, and apply them to all views from step two, and see which one matches (returns true). For example, at step two, you can have two separate views, one for young people, other for old people, and you apply the rules from each view to decide if you show the old or young view.
I could give you one code example, and you could also do research on your own, since I know nothing about your technical environment. I have used Google Guava's predicates on a similar problem and here it is: suppose we are dealing with Witch objects, and each of them has name(string), age(int) and spells(collection) attributes. If I have a list of witches and I need to sort them based on specific criteria, I can do:
// first I want to sort witches by age(natural ordering) then by spells,
// and then by name lexicographically
Ordering.natural()
.compound(new BySpellsWitchOrdering())
.compound(new ByNameWitchOrdering())
.sortedCopy(witchList);
The above line of code is going to take the witch list and return a list of sorted witches according to the criteria. Your situation is pretty similar.
Next, how to create the answers? For each view(page), you have possible answers, like, for view#1, you can have : age, sex, race, country. You can construct some answers, in the form of strings, ints, enums, and pass them to the controller, which in turn is going to apply them to each view corresponding to the next step.
As for how to store the rules in the database, as an example, you could have a column defining rule name (like, OLDER THAN) and one column for value, say, 30. Again, I do not know that much about your environment, and it is a really general issue, so I will stop here...
I'm not a programmer, but trying to learn. I'm a nurse, and need to pull data for medical referral tracking from a database. I have a piece of GUI software which builds JOIN queries for me to pull things from the database. One of the operators I can use in the drop-down is "IN." The referral documentation is stored in the table as codes made up of one to three letters. For example, the code for a completed dental referral is CDF, and the code for a dental referral is D.
I want to build a report to allow other nurses to pull all their outstanding referrals, so I'll want to pull "D" but not "CDF"
If I use IN as the operator, and set my parameters to 'S','D','BP' {etc} will that also pull the records which have the other, longer codes which contain those same letters? (like CDF, CSR, CBP)
I don't want to test it because I only have access to the production database, and I don't want to hose up actual patient records. Thanks in advance for any help!
Assuming that the column that holds the referral code holds one and only one code per record (which is what it sounds like) the query should function as you want and will not attempt to match substrings.
In any event, there's no danger that a query in the form IN ('S', 'D', 'BP') will match substrings. To perform substring matches in SQL you have to use the LIKE operator.
The situation in which this will not work is if the referral code column holds multiple codes separated by commas. This is an all-too-common mistake in designing databases but if the product you're using is commercial rather than home-grown, I think it's very unlikely to be the case. If it is, searching it is much more difficult.
I am not sure what SQL is exactly, databases I think, would SQL be the thing to use?
I want it so that when a user types into a search box it displays a "did-you-mean" box, that also shows how many other people used that term but I will do later ;)
currently I just want the text to be saved into database (?) and also how many times it's been done.
(new to stackoverflow so sorry if format/whatever is bad)
You just need a three table named something like search_queries which has columns for: id, search_text, and count. Everytime somebody searches just increment the count column where search_text is equal to what they searched for. This is a really broad question though and you need to start by learning the basics and report back here with more specific questions.