Knowee
Questions
Features
Study Tools

Write a query to display the owner_name and mail id in which the string should end before the '@' symbol. Display the details of the buildings which are having the  email address and give an alias name as 'email_name' and display it in ascending order based on owner name.Note:1. Display only the owner name and mail id in which the string ends before the @ from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Use SUBSTR function5. Compare your executed result with the sample output given below.Sample output:[only few records shown here]

Question

Write a query to display the owner_name and mail id in which the string should end before the '@' symbol. Display the details of the buildings which are having the  email address and give an alias name as 'email_name' and display it in ascending order based on owner name.Note:1. Display only the owner name and mail id in which the string ends before the @ from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Use SUBSTR function5. Compare your executed result with the sample output given below.Sample output:[only few records shown here]

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The language of the text is SQL (Structured Query Language). Here is the query based on your requirements:

SELECT owner_name, 
       SUBSTR(mail_id, 1, INSTR(mail_id, '@')-1) AS email_name
FROM building
WHERE mail_id IS NOT NULL
ORDER BY owner_name ASC;

This query works as follows:

  1. SELECT owner_name, SUBSTR(mail_id, 1, INSTR(mail_id, '@')-1) AS email_name: This line selects the owner_name and a substring of the mail_id from the building table. The substring starts at the first character of mail_id and ends just before the '@' symbol. The substring is given an alias email_name.

  2. FROM building: This line specifies the building table as the source of the data.

  3. WHERE mail_id IS NOT NULL: This line filters out the records where mail_id is null.

  4. ORDER BY owner_name ASC: This line sorts the result in ascending order by owner_name.

This problem has been solved

Similar Questions

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'.Note:1. Display only the owner name and concatenate contact_number and email with – seperated from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Use CONCAT function5. Compare your executed result with the sample output given below.

Write a query to display the owner_name, address and contact_number of the buildings which does not have an email_address. Display the records in ascending order based on their owner_name.Note:1. Display only the columns owner_name, address and contact_number present in the building table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on email_address column. If email_address is NULL, then it indicates email_address does not present).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output: [Only few records are shown here]

Write a query to display the owner name and the length of the owner's name of the buildings. Display the records in ascending order based on owner name. Give an alias as name_length to the length of the owner names.Use the inbuilt function length().Note:1. Display only the owner name and length of the owner_name from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Compare your executed result with the sample output given below.Sample output:[only few records shown here]

QueryQ14Write a query to display the owner_name, address and contact_number of the buildings which does not have an email_address. Display the records in ascending order based on their owner_name.

Write a query to display the first 3 characters of the owner_name and the contact_number of all buildings in ascending order based on the owner name of the building. Give an alias to the first 3 characters as 'name_code'.Note:1. Display only the first 3 characters of owner names and contact_number from building table.2. Specify the alias name without any mistake.3. Order by is mandatory.4. Use the inbuilt function lpad().5. Compare your executed result with the sample output given below.Sample output:[only few records shown here]

1/3

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.