In Oracle you can take a sample of a dataset like so:
select * from table sample(10);
What's the equivalent to this in HBase?
No. There is no equivalent to Oracle's sample syntax.
Related
As below substring is developed by Greenplum platform, we have to migrate similar operation to Hive supported. kindly help us.
select substring(a.dealer_msisdn from char_length(a.dealer_msisdn)-9) as dealer_msisdn
example of msisdn value with above query for greenplum
select substring('9970050916' from char_length('9970050916')-9) as dealer_msisdn
Please help me similar operation needs to migrate hive.
In hive substring function syntax is different:
substr(string|binary A, int start, int len), len is optional parameter.
Try this:
select substr('9970050916', char_length('9970050916')-9)
Read Hive UDFs manual
my query is like : with bigQuery as ( ) select * from bigQuery ;
how to write it with HQL ??
You can't. HQL can be used with mapped tables only; you can't use it to create tables on the fly. Use native SQL if you need to do this. further info HERE
I am converting Teradata syntax to Oracle.
I have this
SELECT * FROM TABLE_A
WHERE proc_name LIKE any ('%AB%','%AC%')
in Teradata but it is not supported in Oracle.
Does anyone know what is the alternative syntax of Like any in Oracle?
Thanks a lot!
Use or:
SELECT *
FROM TABLE_A
WHERE proc_name LIKE '%AB%' or
proc_name LIKE '%AC%';
This is the "normal" way the logic would be expressed in SQL.
Oracle also supports regular expressions, so if you prefer:
SELECT *
FROM TABLE_A
WHERE regexp_like(proc_name, 'AB|AC');
The two likes probably have better performance.
I want to compare data between two different db tables in netezza. In oracle we can do that by minus operator. How can the same operation be done in netezza.
SELECT CUSTOMER_SRC_ID,CUSTOMER_SRC_DESC FROM CIDB_SIT..CUSTOMER_SRC
MINUS
SELECT CUSTOMER_SRC_ID,CUSTOMER_SRC_DESC FROM EDW_SIT..CUSTOMER_SRC
Seems like it doesn't work in netezza. Can any one help me find the equivalent query in netezza?
The ANSI-SQL standard calls this operators except. Netezza implements it, as do PostgreSQL and MS SQL Server:
SELECT CUSTOMER_SRC_ID,CUSTOMER_SRC_DESC FROM CIDB_SIT..CUSTOMER_SRC
EXCEPT -- Here
SELECT CUSTOMER_SRC_ID,CUSTOMER_SRC_DESC FROM EDW_SIT..CUSTOMER_SRC
You could use the EXCEPT
or
--if customer_src_id is unique--
SELECT CUSTOMER_SRC_ID,CUSTOMER_SRC_DESC
FROM CIDB_SIT..CUSTOMER_SRC
WHERE CUSTOMER_SRC_ID NOT IN (SELECT CUSTOMER_SRC_ID FROM EDW_SIT..CUSTOMER_SRC);
I am trying to write an SQL query which needs to be compatible on both a Sybase and Oracle database. The query looks like the following :
SELECT *
INTO new_table
FROM other_table
This query is working great on a Sybase database but not on an Oracle one. I found the equivalent for Oracle :
CREATE table new_table AS
SELECT *
FROM other_table
Is there a way to write a third query that would do the same and that can be executed on a Sybase and on an Oracle database?
As you found, Oracle supports INTO but doesn't use it like Sybase/SQL Server do. Likewise, Sybase doesn't support Oracle's extension of the CREATE TABLE syntax.
The most reliable means of creating a table & importing data between the systems is to use two statements:
CREATE TABLE new_table (
...columns...
)
INSERT INTO new_table
SELECT *
FROM OLD_TABLE
Even then, syntax is different because Oracle requires each statement to be delimited by a semi-colon when TSQL doesn't.
Creating a table & importing all the data from another table is a red flag to me - This is not something you'd do in a stored procedure for a production system. TSQL and PLSQL are very different, so I'd expect separate scripts for DML changes.
There is no query that would do what you want. These environments are very different.
It is possible.
SELECT * INTO new_table FROM existing_table;
Thanks