Moving consecutive results to different columns - teradata-sql-assistant

I have the following table:
Transaction Id
Authorizer
1
john
1
robert
2
Jane
2
Paul
And the result table I need is like this:
Transaction Id
Authorizer_1
Authorizer_2
1
john
Robert
2
Jane
Paul
How can i make this in Teradata SQL assistant?
Thanks in advance!

Related

MySQL Split String Into Separate Rows Using RegEx

I have some text data in a column similar to this in MySQL 8.0.30:
Id
Weights
1
James Brown 10-10 John Doe 12-9 Sue Smith 9-9 Dick Turpin 9-12
2
Some Other 9-1 Example Name 8-13
There could be any number of name/weight combinations in the column. I want to pull these out into separate rows like so
Id
Weights
1
James Brown 10-10
1
John Doe 12-9
1
Sue Smith 9-9
1
Dick Turpin 9-12
2
Some Other 9-1
2
Example Name 8-13
I've tried using the regex_substr to no avail as I could only get it to return a single match. How could I go about doing this?

Db query to return records where condition1=true alone or condition2=true alone, but not when condition1 and condition2=true collectively

user | manager | permission
-------------------------
adam john 1
adam john 2
adam john 4
dave john 1
dave john 2
dave john 3
dave john 4
ben rick 3
ben rick 4
ben rick 5
ed susan 2
ed susan 3
carl susan 1
carl susan 4
nancy peter 3
nancy peter 4
i want a query which would return user's having permission 2 but not 3 OR having permission 3 but not 2 BUT i DONT want users who have both permissions 2 and 3 and users who dont have both permissions 2 and 3
user
-----
adam
ben
nancy
If you filter for who have permission 2 or 3 you can group and filter for who only have one permission in 2,3
SELECT
user
FROM table
WHERE permission IN (2, 3)
GROUP BY USER
HAVING COUNT(permission) = 1;
You can group by user and check so that the max and min permissions are equal to either 2 or 3:
select user from tablename
where permission in (2,3)
group by user
having
(min(permission) = 2 and max(permission) = 2)
or
(min(permission) = 3 and max(permission) = 3)

How to select value if only all criteria are met?

First time Poster here so I appoligize about the formatting and am really novice at sql, but this has me stumped. That and I am using 2016 MS Access's SQL as well.
I have a table and I want to select only the names of the people who have fulfilled all the requirements.
Table Chore
ID Name Chore Done
1 Joe Sweep Yes
2 Joe Cook Yes
3 Joe Dust Yes
4 Bill Vacuum No
5 Bill Dust Yes
6 Carrie Bathroom Yes
7 John Cook No
8 John Beds No
9 John Laundry Yes
10 Mary Laundry No
11 Mary Sweep No
12 Cindy Car Yes
13 Cindy Garden Yes
In this case, only Joe, Carrie and Cindy's names should be returned because under their name, they finished all their chores.
Help please and thanks in advance!
You can use not in
select name from my_table
where name not in (select name from my_table where chore_done ='No');
You could check the value of max(done), like
select
name
from
my_table
group by name
having max(done) = -1
In Access, Yes/True is -1, No/False is 0, so max(done) is Yes

Relational Algebra: Natural join with NULL value

Table 1
Customer id city
John 1 LA
Nancy 2 NULL
Table 2
Customer $ in the pocket
John 20
Nancy 30
I am wondering what happen if Table 1 natural join with Table 2? My guess is that the result would be 4 attributes and both John and Nancy will appear.
But my friend told me that only John will appear, Nancy won't because there is a null value.
In the case above, your friend is wrong, you are right!
Let's see a case where it would be otherwise:
Table 'Customer'
Id Name AccNo
1 John 44
2 Nancy NULL
Table 'Account'
AccNo $_in_Pocket
44 20
45 30
Here, with a natural join, we would get all attributes for John but Nancy would be missing from the results.

MySQL update the column with conditions

I am trying to update (middle name - mname) a database table based on a certain condition. SQLfiddle. http://www.sqlfiddle.com/#!9/3c022/2
I would like to know HENRY {null} FORD is belonging to one of other HENRY {A,B} FORD based on the coauthors and update the table.
The author with null middle name is updated with the middle name of the author with the same first and last name and with whom he has more number of common co-authors.
For example, based on the data the results is:
HENRY FORD HENRY FORD ---> this should be updated 'B' due to more common authors
HENRY A FORD HENRY A FORD
HENRY B FORD HENRY B FORD
However,
JACK SMITH JACK SMITH ---> this shouldn't be updated due to no common authors
JACK A SMITH JACK A SMITH
JACK B SMITH JACK B SMITH
Any suggestions are appreciate.