adding multiple entries side by side in talend - csv

I have customer_data.csv as follows:
first_name,last_name,cust_no
Test,User1,12345
Test,User2,99999
My address_Details.csv is as follows:
addr_type,line1,line2,line3,cust_no
work,x,y,z,12345
school,a,b,c,12345
Homehome, ,m, ,n, ,o, ,12345
work,1,2,3,99999
My final output should be as follows:
first_name,last_name,cust_no,no_of_addrs,add_type,line1,line2,line3
test,User1,12345,3,work,x,y,y,school,a,b,c,home,m,n,o
test,User2,99999,1,work,1,2,3,,,,,,,,
Where each id has the number of entries joined together?
I used map
I have gotten the following result:
Test|User1|12345|work|x|y|z
Test|User1|12345|school|a|b|c
Test|User1|12345|home|m|n|o
Test|User2|99999|work|1|2|3
What component must I use instead?

1st: the main must be customer_data.csv and the lookup must be address_Details.csv.
2nd: if you want to reject customer without any address, in the tMap, click on the wrench in the lookup table then select "inner join" and on the outpu table, click the wrench and select "catch lookup inner join reject" to True (False is the default).
Regards,
TRF

Related

Match domain and extension of two email addresses in MySQL?

I have two tables with email addresses. Some emails have sub-domains, and others don't. I need to LEFT OUTER JOIN these tables based on the domain name and extension, while ignoring any sub-domains and anything left of the # symbol.
Contacts.Contact
Managers.Manager
bob#api.ibm.com
sarah#ibm.com
jim#sales.ibm.com
jane#mgt.yahoo.ca
joe#ibm.com
fred#google.com
zoe#yahoo.com
sam#facebook.co.uk
elf#api.yahoo.ca
frank#yahoo.ca
jack#oracle.com
SELECT Contact.Contact,
Managers.Manager
FROM Contact
LEFT OUTER JOIN Manager ON ???
should yield the following results:
Field: Contact
Field: Manager
bob#api.ibm.com
sarah#ibm.com
jim#sales.ibm.com
sarah#ibm.com
joe#ibm.com
sarah#ibm.com
zoe#yahoo.com
elf#api.yahoo.ca
jane#mgt.yahoo.ca
frank#yahoo.ca
jane#mgt.yahoo.ca
jack#oracle.com
The ibm.com and yahoo.ca emails were matched. So basically, the pattern is: IGNORE#IF_THIS_EXISTS_THEN_IGNORE.MATCH.MATCH Is this possible? If it is, then what is the correct SELECT statement to yield these results? Thanks.
To extract the (at most) two domain parts on the right, just do:
substring_index(substring_index(email,'#',-1),'.',-2)
Apply that to both Contact and Manager and join on the results being equal.

correctly fetch nested list in SQL

I have a design problem with SQL request:
I need to return data looking like:
listChannels:
-idChannel
name
listItems:
-data
-data
-idChannel
name
listItems:
-data
-data
The solution I have now is to send a first request:
*"SELECT * FROM Channel WHERE idUser = ..."*
and then in the loop fetching the result, I send for each raw another request to feel the nested list:
"SELECT data FROM Item WHERE idChannel = ..."
It's going to kill the app and obviously not the way to go.
I know how to use the join keyword, but it's not exactly what I want as it would return a row for each data of each listChannels with all the information of the channels.
How to solve this common problem in a clean and efficient way ?
The "SQL" way of doing this produces of table with columns idchannel, channelname, and the columns for item.
select c.idchannel, c.channelname, i.data
from channel c join
item i
on c.idchannel = i.idchannel
order by c.idchannel, i.item;
Remember that a SQL query returns a result set in the form of a table. That means that all the rows have the same columns. If you want a list of columns, then you can do an aggregation and put the items in a list:
select c.idchannel, c.channelname, group_concat(i.data) as items
from channel c join
item i
on c.idchannel = i.idchannel
group by c.idchannel, c.channelname;
The above uses MySQL syntax, but most databases support similar functionality.
SQL is made for accessing two-dimensional data tables. (There are more possibilities, but they are very complex and maybe not standardized)
So the best way to solve your problem is to use multiple requests. Please also consider using transactions, if possible.

Create a double join query using Rails Admin

I am trying to create a form using Rails Admin, version 4.0.0. For this form I have tables called items, locations, cities and item_in_city. Tables are related in the following ways:
items table has a column called location which is array or location ids where item is present
location table has a column called city_id which connects it to city table
there is item_in_city table which has item_id and its corresponding list of city_id
Now, I want to create a form using Rails Admin, where I can give option to add a new item. While adding this new item I want to give an option to select (multiple) cities and corresponding to cities I want to give list of locations which can be selected.
I figured out the solution, So I thought of posting it as it can be useful to others. Combination of city name and location can be posted by defining an enum method in the following way
def location_enum
Location.all.collect {|l| [ l.city.name + ' ' + l.name, l.id] }.sort
end

Select ALL in SSRS

I have a table based on three drop down lists. The first is a client list, the second is a date list and the third is a stage list. The first two are single value lists. I can only allow the user to select 1 from each of those lists. The third list is a stage list. This contains the values First,Final and Release. My client has come back to me and asked if I can supply them with the ability to select all of the stages as an option. Here is the query as I have it right now. I have tried using (AnnotationDate IN (#Stage)) in place of (AnnotationDate = #Stage) but was unsuccessful. Can anyone give me a helpful hint?
SELECT AdDate, Page_ID, Status, AnnotationNumber, AnnotationBy, [Role Description], AnnotationDate, AnnotationType, BusinessUnit, ActualAgencyError, ErrorType,
AnnotationComments, TeamComments, sgkComments, PA, Client, Activity, Support, Name, BusImpact
FROM vwAgencyErrorOpen
WHERE (Client = #Client) AND (AdDate = #Job) AND (AnnotationDate = #Stage)
ORDER BY Page_ID
Change your #Stage Parameter to be multi-seletion.
Then remove the (AnnotationDate = #Stage) clause from the query.
And then set up a filter on your dataset as below:
You can then select all of your options.

Forcing multiple JOINs

I have a CASE_MEMBER table with a row for each case member, and a field to indicate the member's role on the case. Let's say role 'Parent' and role 'Child'.
In the universe I've added the CASE_MEMBER table, and created a Parent object and Child object, each object containing a WHERE statement which specifies the correct value of the role field.
Now if I try and create a report with both of these objects, it will join to CASE_MEMBER only once, with a condition of "where role = 'Parent' and role = 'Child'", which is obviously impossible.
So I need to force the query to join to CASE_MEMBER once for each member type. Is the only way to do this by creating multiple aliases of CASE_MEMBER? Or is there another way to do this that also keeps my universe structure looking clean and more resembling the actual data model?
Create an alias of CASE_MEMBER, and include the WHERE condition in the join. So your joins will be:
For CASE_MEMBER to DEMOGRAPHICS:
case_member.member = demographics.memberid and case_member.role='child'
For CASE_MEMBER to DEMOGRAPHICS_PARENT (alias of DEMOGRAPHICS):
case_member.member = demographics_parent.memberid and case_member.role='parent'
Let's say you create (using the field names from your other question), a "Case ID" object from case_member.caseid, "Child SSN" from demographics.ssn, and "Parent SSN" from demographics_parent.ssn. Creating a report with all three of these objects will produce:
SELECT
case_member.caseid,
demographics.ssn,
demographics_parent.ssn
FROM
case_member,
demographics,
demographics demographics_parent
WHERE
(case_member.member = demographics.memberid
and case_member.role='child')
(and case_member.member = demographics_parent.memberid
and case_member.role='parent')
which should produce what you want.
Note that in this example, since we are including BOTH the child and parent table, we will get two rows in the result set. One with a blank child SSN and one with a blank parent SSN. To avoid this, you'd need to put a max() around each one.that