Write a query to display the first 3 characters of each meter number. Give an alias name for the meter number as 'meter_code'.Display the records sorted by meter_code in descending order.Note:1. Display only the first 3 characters of each meter from meter table.2. Specify the alias name without any mistake.3. Order by is mandatory.4.Use the inbuilt function substr().5. Compare your executed result with the sample output given below.Sample output:[only few records shown here]
Question
Write a query to display the first 3 characters of each meter number. Give an alias name for the meter number as 'meter_code'.Display the records sorted by meter_code in descending order.Note:1. Display only the first 3 characters of each meter from meter table.2. Specify the alias name without any mistake.3. Order by is mandatory.4.Use the inbuilt function substr().5. Compare your executed result with the sample output given below.Sample output:[only few records shown here]
Solution
Based on your instructions, it seems like you are asking for a SQL query. Here is a query that should meet your requirements:
SELECT SUBSTR(meter_number, 1, 3) AS meter_code
FROM meter
ORDER BY meter_code DESC;
This query will select the first three characters of each meter_number from the meter table, give it an alias of meter_code, and then sort the results in descending order by meter_code. The SUBSTR() function is used to extract a substring from a string in SQL.
Similar Questions
Write a query to display the meter_number and updated_meter_number(which is obtained by left padding meter_number with ‘*’ and making it 10 character length field.) . Give an alias name as 'updated_meter_number'. Display the records in ascending order based on meter_number.Note:1. Display only the meter_number and updated_meter_number from meter table. updated_meter_number is obtained by left padding meter_number with ‘*’ and making it 10 character length field.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]
Write a query to display the meter_number from the meter table which got minimum amount of total_units in a month. Display the records in ascending order based on their meter_number.Note:1. Display only the meter_number from the meter table which got minimum amount of total_units in a month.2. Tables involved are meter and bill3. Order by is mandatory4. Compare your executed result with the sample output given below.Sample output:
Write a query to display all the details of the 'meter' whose meter_number starts with 'S' and ends with '6'.Note:1. Display all the columns present in the meter table.2. Specify the condition and retrieve the correct rows in the result. (condition need to be specified on meter_number column)3. You can compare your executed result with the sample output given below.Sample output:
Write a query to display the meter_number of the building_type named 'College'. Display the records in ascending order based on their meter_number.Note:1. Display only the meter_number column present in the meter table where building_type name is ‘College’. Use subqueries to achieve this.2. Tables involved are building_type, building and meter.3. Order by is mandatory4. Compare your executed result with the sample output given below.
Write a query to display all the 'bills' with 'meter' details. Display the records in ascending order based on meter number.Note:1. Display all the columns of bill and meter table2. Use Joins3. Tables involved bill and meter4. Order by is mandatory5. Compare your executed result with the sample output given below.
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.