Filter in SQL from search keyword [closed] - sql

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 3 years ago.
Improve this question
I have one table student. If I filter a student using a keyword "ann", then 1st preference should be student name starts with "ann", then student name contains "ann" in SQL Server.

Use LIKE
SELECT * FROM TABLE WHERE NAME LIKE 'ann%' OR NAME LIKE '%ann%'
ORDER BY CASE
WHEN Name LIKE 'ann%' THEN 1
WHEN Name LIKE '%ann%' THEN 2
ELSE 3
END

Related

Im trying to to figure out what I need to write on sql command oracle [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 1 year ago.
Improve this question
For every customer that lives in Florida, list customer number, last name, first name,
and region.
I will assume that you are trying to get the information from a table called "table".
select customer_number,
last_name,
first_name,
region
from table
where city = 'Florida'

How to update employee email address from employee table (need to change just domain name of all employees) [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 2 years ago.
Improve this question
I have employee table with 100 records and have email-id column in it.
but suppose now company has changed domain of email id example:- earlier it was abc#example.com
now it has changed to abc#gmail.com
so how to update same in employees table only have to change domain name from email id of employee table
Please suggest some way in oracle plsql or sql
You can use REPLACE as follows:
UPDATE EMPLOYEE
SET EMAIL = REPLACE(EMAIL,'#example.com','#gmail.com')

POSTGRESQL: Insert Data from another table [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 2 years ago.
Improve this question
In above table customer ids are listed what I want to do is to get those ids from this table,
create another table named PROMOTION CLASSES where PREMIUM, PLUS AND NORMAL are in columns and put first 100 ids under PREMIUM COLUMN and soon.
Please help.
This creates you table with classification
CREATE TABLE promotion_classes as
SELECT customer_id,
case when customer_id < 100 then
'PREMIUM'
else
'NORMAL'
END as CLASSES
FROM CUSTOMER_TBL

sql same table same column but two data [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
TABLE1
NAME
1. AHMET
2. MEHMET
3. VELİ
4. TEMEL
Select * from TABLE1 WHERE NAME='AHMET' and NAME='VELİ'
Probaly you want IN operator:
Select * from TABLE1 WHERE NAME IN('AHMET', 'VELİ')

Problems with SQL query finding three names with the most records [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 8 years ago.
Improve this question
I have a table and I want to display the 3 names (Ted, Ringo, Paul) that have the most records using an SQL query.
It's a primitive question, but please help me.
my table:
SELECT TOP 3 Name
FROM YourTable
GROUP BY Name
ORDER BY COUNT(*) DESC