How to Split Column Data Based on Identifier - sql

I am using oracle database.
I am having data in this format in my column 1234~2345~3456~4567.
I need a query to split the data in the column based on the identifier '~',so that i can pick out the value after the second occurrence of the identifier.
May i know who can i achieve this.

Take a look at
https://blogs.oracle.com/aramamoo/entry/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement

Related

Partitioning BigQuery table based on nested column

I am trying to partition a BigQuery table based on a timestamp but the column I want to use for partitioning is a nested column and has a parent record. For instance: transaction.timestamp.
I would like to pass the column name as String to a java method. How can I define this column name as String in java when I pass it as a parameter?
I have previously tried partitioning with non-nested columns and it worked fine. Following piece of code does not recognize the column name and results in error:
String columnName = "transaction.timestamp";
I would appreciate your help in figuring this problem out.
For partitioning and clustering: You will need to unnest the column and have it as a first level column.
From the docs:
The partitioning column must be a top-level field. You cannot use a leaf field from a RECORD (STRUCT) as the partitioning column.
https://cloud.google.com/bigquery/docs/creating-column-partitions

Number format in oracle

i have created table in oracle. one column is as follow:
GUID NUMBER(16),
But value of this cloumn is shown 1,01000037073356E15
how can i correct it?
The preferred storage data type for GUID values on Oracle is RAW(16).
A GUID is not a number in the sense that your height is a number -- you are not going to add them together, or take their average, for example.
http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions175.htm
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:77564387253035

Get row values as column names in t-sql

I have a requirement to display row values as column names in a data grid view. I want to get the store names into columns using sql select statement. (Please refer the attached image). I want user to enter some values under each column. So STORE 1, STORE 2, STORE 3 should displays as columns in datagrid view. Does anyone can help me to get this work?
while googling i found this can be done using PIVOT in SQL. But in this table i don't have any aggregate columns. Any help pls?
the result should be somthing like
You may know that your data only contains a single row for each pivoting column, but SQL Server has to construct a plan that could accommodate multiple rows.
So, use PIVOT and just use an aggregate that, if passed a single value, will return that same value. MIN() and MAX() fit that description (as does SUM if you're working with numeric data)
You may use specific function of dynamic pivot and pass your query with item count column.
You can use below link which provided you function and can easily show you expected output.
http://forums.asp.net/t/1772644.aspx/1
Procedure name:
[dbo].[dynamic_pivot]

Sorting table data issue

I've quite bulky data in a Database table and I want to sort the data based on their ID (Primary Key). The data in the key column could be:
001/2011,
002/2011,
001/2012
When I use 'order by id' it sorts the rows like
001/2011,
001/2012,
002/2011
However, what I am looking for is
001/2011,
002/2011,
001/2012
The data type of the id column is varchar(50). Is there a special SQL function that I should use to sort such type of data?
ORDER BY RIGHT(ID,4)+LEFT(ID,3)
This rearranges the varchar data so that the year comes first and the sequence/month/day-of-year comes after.
If you have some other format to your data, then think along the same lines. Shift the string around using SUBSTRING, of which LEFT and RIGHT are just 2 specific versions.

how to find index of a row in sql server?

How can i fetch column names from a table on index basis, like I want to make a tables whose column name should be the name of last column fields of a result set of a query, but those result sets last columns value may be different at different execution time, so i want to know how can i fetch those index value of that last column to make a temp table with column name of those last columns value of a result set.
Is there any way/function in sql server to dynamically form that?
sp_helpindex:
Reports information about the indexes
on a table or view.
You can also use ROW_NUMBER as explained here