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
I am having a database with 2 columns employee and job.Job column contains character in each record.In that,I have to list the employees whose job is having last 3 characters as 'man'.I have to use only functions in SQL Query.
Use LIKE with wildcard:
SELECT *
FROM your_table
WHERE job_column_name LIKE '%man'
or using RIGHT
SELECT *
FROM your_table
WHERE RIGHT(job_column_name, 3) = 'man'
Answer For Question 4 is
SELECT *
FROM emp
WHERE SUBSTR(job,-3,3)='MAN';
Related
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 query for to get data following :
select a from REPLACE(M,',','')TABLE;
I want to get all the data from table along with M column content replce , with space.
You select from the table. What you select belongs in the SELECT clause:
SELECT t.*, REPLACE(m, ',', '') FROM mytable t;
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 a column media_type with sample following values
*media_type*
-------------------
socialmedia, paper
tv
paper, tv
pamplet,board
tv,board,pamplet
I would want to filter my promotions which are being advertised through only one media.
You can use locate():
select *
from mytable
where not locate(',', media_type)
This phrases as: get all rows whose media_type is not null and does not contain a comma.
A more portable approach uses like:
select *
from mytable
where media_type not like '%,%'
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
SELECT location,special,price FROM `tickets`
WHERE event = 'food' GROUP BY location
I think you want, (assuming its mysql) the following:
SELECT location, ANY_VALUE(special) special, ANY_VALUE(price) price
FROM tickets
WHERE event='food'
GROUP BY location ;
ANY_VALUE is strange aggregate function out of normal db standards that returns one of the values arbitarily.
If you wish to not have duplicate results in your rows you can choose only distinct result set.
SELECT DISTINCT location,special,price FROM tickets WHERE event = 'food' GROUP BY location
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 6 years ago.
Improve this question
I have one table with 3 fields e.g.
Name, Team Name, Player_Number
there is multiple team and I want to fetch 2 member from each team.
Please share with fast solution.
Try this
select * from TableName s where (select count(*) from TableName a where a.TeamName = s.TeamName and a.Player_Number >= s.Player_Number) <= 2
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
I have a table with the following values
and I need the output values as below.
Please help to arrive the code
It's not pretty, but this would work:
select *
from
(
select nams_contract_number, 1 as Sequence, 'Preqc' as DataType, act_preqc, est_preqc
from table
union all
select nams_contract_number, 2 as Sequence, 'abstractoin' as DataType, act_abstraction, est_abstraction
from table
union all
select nams_contract_number, 3 as Sequence, 'review' as DataType, act_review, est_review
from table
union all
select nams_contract_number, 4 as Sequence, 'postreview' as DataType, act_postreview, est_postreview
from table
) x
order by x.nams_contract_number, x.sequence