Write a query to display all person names from travel_card table. If the person_name contains the letter 'a'(case sensitive) in it, then substitute the letter 'a' with '*'. Give an alias name for the person names as 'modified_name'. Display the records sorted by person name in ascending order.
Question
Write a query to display all person names from travel_card table. If the person_name contains the letter 'a'(case sensitive) in it, then substitute the letter 'a' with '*'. Give an alias name for the person names as 'modified_name'. Display the records sorted by person name in ascending order.
Solution
Sure, here is the SQL query you asked for:
SELECT
REPLACE(person_name, 'a', '*') AS modified_name
FROM
travel_card
ORDER BY
person_name ASC;
This query will select all person names from the travel_card table, replace any occurrence of the letter 'a' with '*', and then sort the results in ascending order by the original person name. The REPLACE function is used to replace all occurrences of a specified string. The AS keyword is used to rename a column or table with an alias.
Similar Questions
Write a query to display the person_name and contact_number from the 'travel_card'.Display the records in ascending order based on the person_name.Note:1. Display only the column named person_name and contact_number present in the travel_card table.2. Order by is mandatory
Write a query to display the person name,contact number,balance,entry_time and exit_time details of all the persons who is having the second highest balance in their travel cards. Display the records in ascending order based on their person_name.Note:1. Display only the below 5 columns, i. person name ii. contact number iii. balance iv. entry time and v. exit timewith the condition having second highest balance.2. Order by is mandatory.3. Compare your executed result with the sample output given below.
Write a query to display the person_name and the contact_number from travel_card table of every person whose destination station is on the route 'North East line' with the payment more than 25. Display the records in ascending order based on person name.Note:1. Display only the person_name and contact_number from the travel_card table whose travel_payment destination route North East line with amount >25.2. Tables involved are travel_card, travel_payment and station3. In travel_payment table, the exit_station_id must match with the station id with name ‘North East line’ and amount greater than 25.4. Order by is mandatory.5. Compare your executed result with the sample output given below.
Write a query to display person name,contact number and balance of all the details, who are travelled maximum number of times. If there is multiple record dipsplay the record in descending order by person name.Note:1. Display only the peron name, contact number and balance whose travelled maximum number of times.2. Order by is mandatory.3. Compare your executed result with the sample output given below.
Write a query to display all the owner_name and concatenate contact_number and email with a hyphen(-) separated . Display the records in descending order based on owner_name . Give an alias name as 'contact_details'.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.