how to display employee names starting with a and then b in sql
To get employee names starting with A or B listed in order...
select employee_name
from employees
where employee_name LIKE 'A%' OR employee_name LIKE 'B%'
order by employee_name
If you are using Microsoft SQL Server you could use
....
where employee_name LIKE '[A-B]%'
order by employee_name
This is not standard SQL though it just gets translated to the following which is.
WHERE employee_name >= 'A'
AND employee_name < 'C'
For all variants you would need to consider whether you want to include accented variants such as Á
and test whether the queries above do what you want with these on your RDBMS and collation options.
SQL query to get names containing a and b anywhere in the string
I'm guessing you are currently getting 0 rows returned, because you're querying for FName
values that end with a
and end with b
. You're close though.
Just add another wild card to the end of each like
criteria, and it'll look for matches where anything proceeds, or follows, each letter (including beginning or ending of the string).
select FName from Employee where FName like '%a%' AND FName like '%b%'
More information on LIKE
:
https://msdn.microsoft.com/en-us/library/ms179859(v=sql.110).aspx
how to get count of employees whose name starts with alphabet A and B
You can always use CASE
SELECT
SUM(case when first_name like 'A%' then 1 else 0 end) 'A' ,
SUM(case when first_name like 'B%' then 1 else 0 end) 'B'
FROM tableName
Query basically means add 1 to column A for every first_name that starts with A.
List the employees whose name starts with 'S' and ends with 'S'?
It looks like Informatica does not have a LIKE equivalent available. You can use REG_MATCH and insert in a regular expression that will match for starts with S and ends with S. Example Below:
REG_MATCH(ENAME,'[S^]+\w+[S$]')
RegExr Link: http://regexr.com/3b17b
I want to know SQL commands
select *
from employee
where
name like's%'
and
name like'%h';
SQL - print names with letter starting in 's' or ending in 's'. Exclude Males
You can use the like
operator with the asterisk (*) in Access. the *
wildcard represents any number of characters in a string.
SELECT pet_id, Name, Type, Breed, Gender
FROM pet
WHERE (Name LIKE "s*" OR Name LIKE "*s")
and gender <> "M"
MS Access uses the asterisk (*) wildcard character instead of the percent sign (%) wildcard character.
Related Topics
Fetch the Rows Which Have the Max Value for a Column for Each Distinct Value of Another Column
Difference Between "INNER JOIN" and "OUTER JOIN"
Sql - How to Sum/Aggregate Certain Rows in a Table
How to Get Depatment Wise Max Salary as Well as Name of Employee Having It
Selecting the First Day of the Month in Hive
Splitting Date into 2 Columns (Date + Time) in SQL
Sql Query to Show Missing Records from Another Table
Postgresql Query to Return Results as a Comma Separated List
A SQL Query to Get All the Records Where 5 Columns Are Same But Only One Column Is Different
Sql Query to Join Two Tables With No Repeated Values
Select Count of Total Products as Well as Out of Stock Products from Table
Get the Number of Digits After the Decimal Point of a Float (With or Without Decimal Part)
Custom Aggregate Function (Concat) in SQL Server
Mysql Workbench Closes Unexpectedly
Unable to Get Min and Max Time from a Datetime Column from Every Backday