Selecting from different csv in SPARQL - sparql

Hi I have two csv data sources.
The csv contains name of employees.
csv1 with heading: Name
Contents: Jack, Tom, Andy, Jim, Stella.
csv2 with heading: EmployeeName
Contents: Bella, Stefan, Jim, Cathy, Jack
Now I need a SPARQL query, where I can search the two csv, and have a variable where both the data can be combined avoiding duplicates(for ex: avoiding Jim and Jack in this instance, but getting data of these names only once)

Related

Alteryx Designer - How to retrieve only first and last name from field excluding middle initials?

I need help in writing SQL code in Alteryx Designer.
My table employees contains a column Name with values shown below. However, I need the expected output as shown below.
Please help.
Name:
Smith, Mary K
Koch, J B
Batoon Rene, Anne S
Vaughan-tre Doctor, Maria S
Excepted output:
Smith, Mary
Koch, J
Batoon Rene, Anne
Vaughan-tre, Maria
The middle initials and “Doctor” word is removed.
Not sure why you need to use SQL if you have the data in Alteryx?
So, you need to remove the right hand 2 characters and the word 'Doctor' from each record?
You could use the Formula tool, though I suspect there are numerous other ways:
replace (TrimRight([Name],' '+right([Name],1)),'Doctor','')

Access Query for 2 tables with similar data

I have two tables that have a column labeled Name:
[CurrentRecords].[Name]
[tbl_vPC].[Name]
However, the CurrentRecords table has more info on each name such as jr, sr, II, III, etc, but the tbl_vPC does not contain that extra information.
Example:
CurrentRecords has: ROBINSON, ROBERT E JR
tbl_vPC has: ROBINSON, ROBERT E
CurrentRecords has: ALLEN, DUG V III
tbl_vPC has: ALLEN, DUG V
Is there a query where I can find all records in the CurrentRecords and all records in tbl_vPC that are similar?
Name is a reserved word. Should not use reserved words as names.
This is why name parts should be in separate fields. Parsing first and last names might not be terribly difficult because of the comma, assuming EVERY record has this convention and EVERY record has value in this field. Try in queries for each table:
x represents Name field
LastName: Left(x, InStr(x, ",")-1)
FirstName: Left(Mid(x, InStr(x,",")+2), InStr(Mid(x, InStr(x,",")+2)," "))

Nonexact duplication, sum rows in pivot table

I have a spreadsheet for payroll that is populated from a seperate spreadsheet. Occasionally,one of our workers will get a promotion. That promotion shows on the timesheets: ex. Smith, Adam Position becomes Smith, Adam Promotion.
This data is then populated into a pivot table where Smith, Adam Position and Smith, Adam Promotion show in separate cells. Currently, we are manually adding the two data sets so that payroll gets a single number instead of multiple. I would like to simplify this tasks. I am using excel 2003, so some more advanced functions don't work.
Any suggestions and help would be greatly appreciated. Thanks in advance.
Ideally, you'd use a different field (a unique identifier) to identify Smith, Adam (e.g., an employee ID number), but if that's not available, then you could take the following approach:
(Suppose that "Smith, Adam Position" is in A1.)
You could add an additional column that extracts the last name, the comma, and then whatever the next word is. For example, from
Smith, Adam Analyst
you would get Smith, Adam. Unfortunately, this means that If you have something like
Jones, Mary Ellen Consultant
you would end up with Jones, Mary. If you think you can live with that, this solution could work. The way you would extract that would be with the following formula:
=SUBSTITUTE(LEFT(SUBSTITUTE(A1,", ",",",1),FIND(" ",A1)-1),",",", ",1)
And then build your pivot table on that field.

How do you query only part of the data in the row of a column - Microsoft SQL Server

I have a column called NAME, I have 2000 rows in that column that are filled with people's full names, e.g. ANN SMITH. How do I do a query that will list all the people whose first name is ANN? There are about 20 different names whose first name is ANN but the surname is different.
I tried
and (NAME = 'ANN')
but it returned zero results.
I have to enter the FULL name and (NAME = 'ANN SMITH') ANN SMITH to even get a result .
I just want to list all the people with there first name as ANN
Try in your where clause:
Where Name like 'ANN %'
Should work mate.
ANN% will find all results where ANN is first then anything after.
%ANN% will find the 3 letters ANN in any part of that rows field.
Hope it helps
Also usually Name is separated into First names and second name columns.
this will save Having to use wild cards in your SQL and provide A bit more normalized data.
SELECT NAME
FROM NAMES
WHERE NAME LIKE 'ANN %'
This should wildcard select anything that begins with 'ANN' followed by a space.

SSIS - export from SQL table to multiple flat files based on first column values

Here is an example of what the SQL Table looks like:
Name Class Grade
Jesse English A
Jesse Math C
Jesse History A
Scott Math B
Scott History B
Scott English A
Mike History A
Mike English D
I am trying to get SSIS to dynamically create a flat file for each person. Example:
Flat File name: Jesse
Name Class Grade
Jesse English A
Jesse Math C
Jesse History A
Flat File name: Scott
Name Class Grade
Scott Math B
Scott History B
Scott English A
Flat File name: Mike
Name Class Grade
Mike History A
Mike English D
I can easily create a static link between the sql table and the flat file but I plan on adding a lot of people to the table which would otherwise cause me to create a data flow task for each. This would not be ideal. I was hoping for a for each loop that identified the distinct values within the Name column and then output the qualified rows into a flat file.
This is how your package should look like :
right click->variable 1.student-->object
2.students-->string(for holding all names of students giving you required) result
In the data flow -- connection managers--right click-- flat file connection-->properties-->expression mention it as something like this ::"C:\\Users\\user\\Desktop\\ssis_stuff_from_stackoverflow\\citys.txt-"+ #[User::student] +".txt"
the package succesfully executes affecting 3 rows and adding 3 flat files in the folder
path
here is one good example
First run a query to find a recordset of unique students:
select distinct name from myTable
Then use the foreach loop to loop though and run the following parameterized query:
SELECT class, grade
FROM myTable
WHERE name = ?
Use a derived column to include the name to the resultset.
Put this in a flat file destination. The connectionstring for the output file will be dynamic.
These are the steps. If you get stuck, there are plenty of examples online, or feel free to ask.