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]
Question
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]
Solution
The language of the text is SQL (Structured Query Language). Here is the query you need:
SELECT
meter_number,
LPAD(meter_number, 10, '*') AS updated_meter_number
FROM
meter
ORDER BY
meter_number ASC;
This query does the following:
- Selects the
meter_numberfrom themetertable. - Uses the
LPADfunction to left pad themeter_numberwith '*' until it becomes a 10 character length field. This new field is given an alias name 'updated_meter_number'. - Orders the result in ascending order based on
meter_number.
Similar Questions
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.
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 'meter_number' from meter table.
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.
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:
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.