Skip to content

XQUERY -SQL Retrieve list of child and parent ID

How I can query the xml in order to obtain the following result? I am completely new on using XQuery. XML sample: And the result: idAsig B1_1 B1_2 B1_3 B1_4 B1_5 1 NULL NULL NULL NULL NULL 2 1 0 N 8 4848 2 52 0 N 8 625 3 1 0 N 8 589 3 39 0 N 8

Oracle hierarchical queries data

The link gives a good example for overview on how to use Oracle hierarchical queries. I was trying to generate the below combination of data with the example table tab1 given in the link but struck …

Convert utc string to date SQL

I’ve a column sample_date in form of string as 200912301111230000000000 (UTC Time).How can I convert it from string to datetime in form of yyyymmdd using SQL select statement? Answer As you only want yyyymmdd, which is the first 8 chacters of your string, it is enough to simply use LEFT I added the ST_T…

count(distinct request_ip) GROUP by date

I have the following SQL, which I am using against AWS ELB logs stored in S3 with AWS Athena. SELECT count(distinct request_ip) AS count, request_ip, DATE(from_iso8601_timestamp(timestamp)) AS date …

SQL union grouped by rows

Assume I have a table like this: col1 col2 col3 col4 commonrow one two null commonrow null null three How to produce a result to look like this: col1 col2 col3 col4 commonrow one two three Thanks Answer like this, you can group by col1 and get the maximum in each group: