How Do I Capture Duplicate Column Record using 1 Column with 2 Different Results - obiee

I'm a novice creating OBIEE analysis. I searched this site looking for an answer and can't find the exact one I need.
Is there a way to capture unique IDs from one column that have two different results in another column?
How do I capture the Employee IDs that have two different ticket numbers?
ID Ticket Result
123 201 Hired
123 301 Retired
456 201 Hired
789 317 Resigned
888 210 Temp Hire
777 249 Seasonal Hire
666 209 Hired PT
666 310 Removed
456 339 Death
Expected results:
123
666
456

Related

Microsoft Power Automate Condition

Dears
Greetings,,
I'm trying to create a Ms flow that uses condition if any one of these employees numbers submit a form consider it as yes others no.
If possible get the chosen employees from the excel table
employees numbers:
1115
1114
2150
2233
3322
5555
etc
more than 50 employees numbers
I would use a Filter Array to check if the single item is part of a Employees numbers array. After that you can check if it has a match.
Belows is an example with a manual trigger to give you an idea of the approach.

Slow update query in Oracle - what am I doing wrong?

Update queries have never been my strong point, I am hoping someone can help me make a more efficient query?
I am trying to update a table with the total sales for a given product, for a given customer.
The table I am looking to update is the sales column of the below 'Estimate' table:
ID Customer Product Estimate Sales
--------------------------------------------
1 A 303 100 20
2 A 425 20 30
3 C 1145 500 250
4 F 801 25 0
The figure I am using to update is taken from the 'Sales' view:
Product Customer Actual
------------------------------
303 A 30
500 C 2
425 A 88
1145 C 700
The query I have written is:
UPDATE estimate e
SET e.sales = (SELECT s.actual FROM sales s
WHERE e.customer = s.customer and e.product = s.product)
WHERE EXISTS (SELECT 1 sales s
WHERE e.customer = s.customer and e.product = s.product)
An added complication is that 'estimates' exists between a range of dates and need to be updated for sales during that period only. My 'sales' view above take care of that, but I have left this out of the example for simplicity sake.
I initially ran the query using test data of only around 20 records and it ran in around 3 /4 seconds. My actual data is 7,000+ records and when I run the query here, my browser times out before I get any results.
I suspect that the query is updating the whole table for every record in the view or vice versa?
Any help much appreciated.
Cheers
Andrew
Try a merge instead:
merge into estimate tgt
using sales src
on (tgt.customer = src.customer and tgt.product = src.product)
when matched then
update tgt.sales = src.actual;
By doing the merge instead of an update, you negate the need to repeat the query in the set clause in the where clause, which ought to speed things up a bit.
Another thing to check is how many indexes do you have on the estimate table that has the src column in it? If you have several, it might be worth reducing the number of indexes. Each index that has to be updated is an overhead when you update the row(s) in the table.
Also, do you have triggers on the estimate table? Those might be slowing things down as well.
Or maybe you're missing an index on the sales table - an index on (customer, product and sales) ought to help, as the query should then be able to avoid going to the table at all since the data it needs from that table would all be in the index.
Another argument you could have is to not do the update at all. If the information is available in the Sales table, why do you need to bother updating the estimate table at all? You could do that as a join when querying the estimate table. Of course, it depends on how often you'd be querying for the estimate vs actual sales information vs how often they'd be updated. If you update frequently and read infrequently, then I'd skip the update and just query the two tables directly.

How do I output the results of a HiveQL query to comma separated or pipe separated file?

Suppose we have a HIVE table like this
name id age
jones 12 34
george joseph 13 45
bush 15 23
Now i want to output this hive table to csv and pipe separated file.
I followed steps in How do I output the results of a HiveQL query to CSV?.
hive -e 'select books from table' | sed 's/[[:space:]]\+/,/g' > /home/lvermeer/temp.csv
But its working this these
name id age
jones 12 34
george joseph 13 45
bush 15 23
I want george joseph to be in 1 column. Since george joseph contains middle spaces, its outputting to next column. How to resolve this problem ??
In case your query doesnt contain join or so criterias then You could easily get the data from the corresponding HDFS location. The data would be |(pipe) seperated as per the delimiters mentioned.
Hive columns are separated by '\t', assuming "george" and "joseph" are separated by space, you don't have any problems. You can check out separators with vim, just type :set list. Tabs would be marked as ^I
To view output file, you can use, for example, LibreOffice Calc, but you have to be sure, that you are using as delimiters only tabs, not spaces

ORACLE - insert records by multiple user on PK table

In oracle I have a table say EMPLOYEE(EMPID,EMPNAME) with primary key on EMPID.
Two users are having insert privileges to this table say USER1 and USER2.
User1 insert a record with EMPID=1 and EMPNAME='XYZ' and not committed. But if USER2 is trying to insert the same record EMPID=1 and EMPNAME='XYZ' then the screen get hangs till user1 commits or rollback.
Is there option to insert this record by both the users with out any hang and the user who commits second should get the PK violation error.
Thanks,
Niju Jose
In a single-user database, the user can modify data in the database without concern for other users modifying the same data at the same time. However, in a multiuser database, the statements within multiple simultaneous transactions can update the same data. Transactions executing at the same time need to produce meaningful and consistent results.
Isolation Level Dirty Read Nonrepeatable Read Phantom Read
---------------- ------------ ------------------ -------------
Read uncommitted Possible Possible Possible
Read committed Not possible Possible Possible
Repeatable read Not possible Not possible Possible
Serializable Not possible Not possible Not possible
In your case, Oracle acquires a row level lock. The insert case is simpler, because inserted rows are locked, but also are not seen by other users because they are not commited. When the user commits, he also releases the locks, so, other users can view these rows, update them, or delete them.
Read here about Data concurrency and consistency.
Also see here more details on Insert Mechanism
To explain more, I reproduce Florin's answer here
For example, let be tableA(col1 number, col2 number), with this data within it:
col1 | col2
1 | 10
2 | 20
3 | 30
If user John issues at time1:
update tableA set col2=11 where col1=1;
will lock row1.
At time2 user Mark issue an
update tableA set col2=22 where col1=2;
the update will work, because the row 2 is not locked.
Now the table looks in database:
col1 | col2
1 | 11 --locked by john
2 | 22 --locked by mark
3 | 30
For Mark table is(he does not see the changes uncommited)
col1 | col2
1 | 10
2 | 22
3 | 30
For John table is:(he does not see the changes uncommited)
col1 | col2
1 | 11
2 | 20
3 | 30
If mark tries at time3:
update tableA set col2=12 where col1=1;
his session will hang until time4 when John will issue an commit.(Rollback will also unlock the rows, but changes will be lost)
table is(in db, at time4):
col1 | col2
1 | 11
2 | 22 --locked by mark
3 | 30
Immediatley, after John's commit, the row1 is unlocked and marks's update will do the job:
col1 | col2
1 | 12 --locked by mark
2 | 22 --locked by mark
3 | 30
lets's mark issue a rollbak at time5:
col1 | col2
1 | 11
2 | 20
3 | 30
So your hang is due to the fact that the Oracle engine is waiting for a commit or a rollback from User1, before giving a definitive response to user2.

Oracle Query for finding non-repeated rows

I will try to put forward this question in a simple way. Consider that I have a table with two columns (Name, Contact_No). We can have the same name but with different Contact No in the table. All I want to know is to find out which name is NOT repeated in the entire table. Or in other words, which name is unique in this table and has appeared only once.. This is just an example, the actual scenario is quite different but if anyone can help me with this example, I'll be able to handle the actual scenario.
Here is an example
Name Contact_No
A 123
A 124
B 125
C 126
C 127
All I want is to find (B) which is not repeated in the entire table. Thanks
You can simply do this:
SELECT name FROM tbl_name GROUP BY name HAVING COUNT(name) = 1
Check Out SQLFIDDLE

Resources