Consider a Phone Log table as below. It records all phone numbers that we dial in a given day.
SOURCE_PHONE_NUMBER
DESTINATION_PHONE_NUMBER
CALL_START_DATETIME
1234
4567
01/07/2011 10:00
1234
2345
01/07/2011 11:00
1234
3456
01/07/2011 12:00
1234
3456
01/07/2011 13:00
1234
4567
01/07/2011 15:00
1222
7890
01/07/2011 10:00
1222
7680
01/07/2011 12:00
1222
2345
01/07/2011 13:00
Please provide an SQL query to display the source_phone_number and a flag where the flag needs to be set to Y if first called number and last called number are the same and N if the first called number and last called number are different.
Desired Output:
Source Number
Is_Match
1222
N
1234
Y
Answers were Sorted based on User's Feedback
Answer / jd
this can be done using FIRST_VALUE() AND LAST_VALUE()
check the below link for more information
http://netezzamigration.blogspot.com/2014/10/lastvalue-and-firstvalue-best-example.html
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / kivi
first value and last value...
for more info ref
http://etltechsolutions.wordpress.com/2014/10/12/last_value-and-first_value-best-example/
Is This Answer Correct ? | 2 Yes | 1 No |
I have a file with data comming as 1,x1,x2,x3 2,a1,a2 3,b1,b2,b3,b4 1,y1,y2,y3 2,c1,c2,c3 3,d1,d2 my out put should be as follows x1,x2,x3,a1,a2,<null>,b1,b2,b3,b4 y1,y2,y3,c1,c2,c3,d1,d2,<null> Please let me know how can we acheive this in informatica Thanks in advance
how DTM buffer size and buffer block size are related
What happen when you enable grid option avilable at session level ? (Ans found: Scalabily . A single session Parallelization) But how can one session is sharable among different nodes at the same time while running ?
how do u get the first record from 50,000 records ?
10 Answers TCS, UBS,
Difference between Target-based loading and constraint-based loading?
What are the connected or unconnected transforamations?
what r the propertes of workflow? and write quary to select dept more ten employess in dept.?
How do we implement materialized view?when to use materialized view?
IF Sorce table contains CLOB as its one data type then i get error at the target table. How can this be resolve?
Is it possible to update the target table with PK?
How to create or import flat file definition in to the warehouse designer?
How is union transformation utilized?