regexp_like vs like operator : Oracle [closed] - sql

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am searching for multiple phrases using SQL 'like' operator. Same results can be extracted using Regexp_like function in Oracle. Which one is better/efficient to use and why? My observation is that 'like' works much quicker than regEX.
I am running my queries against very large dataset with few million rows.
Here are both the versions of the query
Using like:
select
name
from
table
where
lower(result) like '%the condition is absent%'
or lower(result) like '%partial presence of disease%'
Using Regexp_like():
select
name
from
table
where
regexp_like(lower(result),'^.*(the condition is absent)|(partial presence of disease).*$')

Related

using mid function in bigquery [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a column that has data like this:
TEXT000612
TEXT721
TEXT8
Expected output:
000612
721
8
The column only has a 4 letter text text and its only at the beginning at the cell. But the numbers can vary in length. Also, I want to make sure the numbers are string.
There is no mid function in BQ.
Also, if you dont like my question or think it needs to be improve please give me a chance to improve it before flagging it.
Few options for BigQuery Standard SQL
#standardSQL
SELECT col,
SUBSTR(col, 5),
REGEXP_REPLACE(col, r'^TEXT', '')
FROM `project.dataset.table`
If you just want the numbers, use substr():
substr(col, 5)
You can cast() this to a number if you want.

How to you use Max and Min expression in Ms Access SQL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
CrimeData Table for 12 months
Crime Took place in Easternmost
I need to find the following:
Q.7 What type of Crime takes place in the …
(a) Easternmost ………………..
(b) Westernmost ………………..
(c) Northernmost………………..
(d) Southernmost………………..
I tried to find the crime took place in the Easternmost using the following SQL code
SELECT Max(CrimeData.Easting) AS MaxOfEasting, CrimeData.Type
FROM CrimeData
GROUP BY CrimeData.Type;
but I got more than one crime and also other Easting numbers. Can you please tell me if there are other good ways to find the solution.
Please see the attached pictures :)
Rather than using Max/Min, have a look at the TOP keyword in SQL. Some SQL might look like:
SELECT TOP 1 CD.*
FROM CrimeData CD
ORDER BY CD.Easting DESC;
Regards,

How to check if one table is replica of other table in SQL? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How to find if one table is replica of other table in SQL
In SQL Server, you can compare the results of:
SELECT checksum_agg(checksum(*))
FROM Table1;
SELECT checksum_agg(checksum(*))
FROM Table2;
You could create a join with these as sub-queries if you want, too.
You may wish to use binary_checksum() instead of checksum(). The doc says that checksum() will treat strings that are equal as equal according to the collation (i.e., 'hello' and 'HELLO' if the collation is case-insensitive), while binary_checksum() compares the raw binary values of characters.
This works for MySQL:
CHECKSUM TABLE table_1, table_2;

Do table names with [Name1].[Name2] pattern differ from normal tables? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
When I look at Microsoft's sample AdventureWorks database, I see the table names follow a pattern such as:
[Person].[Address]
Does this kind of specification differ from a normal pattern such as:
PersonAddress
Is it only for readability or is there some other point to it?
It's SchemaName.TableName
So [Person].[Address] != PersonAddress
Instead it'll be Person.Address
The [] are optional, they exist because if you have special characters, or a reserve word in the object name, you will not be able to call the object without them.
For example select last name from people; is not going to work,
instead you need select [last name] from people;
You can find more information here.

Create an ORACLE data dictionary of tables with more than 2 indexes [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm having trouble trying to figure out in an ORACLE data dictionary whether a table has more than 2 indexes.
You can start by looking at a dictionary table such as ALL_INDEXES and trying something like this:
SELECT TABLE_NAME
FROM USER_INDEXES
GROUP BY TABLE_NAME
HAVING COUNT(*) > 2;
I haven't tried the code, or read the doc in detail to see if there may be cases where things show up twice, but it should put you on the track.