Programming

How to convert from Lowercase to Uppercase in SQL?

To convert or change the value of a field from lowercase to uppercase, the UCASE() function is used.   SQL UCASE() Syntax is as follows: Select UCASE(column_name) From table_name;   Let us consider the below Students table: roll_no Name total_marks (out of 600) percentage grade 1 Ashok 392 65.33 B 2 Chaitali 454 75.67 A 3 Smriti 502 83.60 A 4 Kaushik 337 56.10 C   The following SQL statement

How to calculate sum of the numeric columns in SQL?

To sum up or to do the addition of the numeric column of the table,the SUM() function is used.   SQL SUM() Syntax is as follows: Select Sum(column_name) From table_name;   Let us consider the below Students table: roll_no Name total_marks (out of 600) percentage grade 1 Ashok 392 65.33 B 2 Chaitali 454 75.67 A 3 Smriti 502 83.60 A 4 Kaushik 337 56.10 C   Now suppose based

How to find the square root of numeric fields in SQL?

If you want to find the square root of any number, then the SQRT() Function is used. The Select Statement can be used to find the square root of any number as follows:   The SQRT() syntax is as follows: Select SQRT(number);   Example: Select SQRT(25); SQRT(25) 5.000000   You can see the float value because the SQL manipulates the square root in float data type. The SQRT() Function can

How to round off the numbers in SQL?

In order to round off a numeric field in a table that contains decimals, the ROUND() function is used. The numbers will be rounded to the nearest whole number.   SQL ROUND() Syntax is as follows: Select Round(column_name, decimals) From table_name;   Here, decimals mention the number of decimals that are to be returned.   Let us consider the below Students table: roll_no Name total_marks (out of 600) percentage grade

What is the use of random function in SQL?

When a Rand() is called, it displays random numbers between 0 and 1.   You can use Select statement to call Rand() Function:   For example, Select Rand(), Rand(); Rand() Rand() 0.45832146952763 0.72513571983465   It can be seen above that, 2 different values are displayed each time. To randomize a set of rows or values, you can use ORDER BY RAND() as follows:   Let us consider the following Students table: roll_no

How to fetch the current system time in SQL?

In order to return or fetch the current date and time of the system, the NOW() function is used.   SQL NOW() Syntax is as follows: Select Now() From table_name;   Let us consider the below Students table: roll_no Name total_marks (out of 600) percentage grade 1 Ashok 392 65.33 B 2 Chaitali 454 75.67 A 3 Smriti 502 83.60 A 4 Kaushik 337 56.10 C   Example: The following

How to calculate minimum value of a table in SQL?

To return or fetch the smallest values from the selected column, the MIN() function is used.   SQL MIN() Syntax is as follows: Select Min(column_name) From table_name;   Let us consider the below Students table: roll_no name total_marks (out of 600) percentage grade 1 Ashok 392 65.33 B 2 Chaitali 454 75.67 A 3 Smriti 502 83.60 A 4 Kaushik 337 56.10 C   Now suppose based on the above

How to extract particular data from a table in SQL?

In order to extract characters from a particular or specified text field, the MID() function is used.   SQL MID() Syntax is as follows: Select Mid(column_name,start,length) From table_name;   Here, start indicates the starting position and length mentions the number of charecters to return. The start parameter is mandatory to specify, but length is optional parameter. If the length is not mention, the the function returns the value from the

How to calculate maximum value of a table in SQL?

To return or fetch the largest value from the selected column, the MAX() function is used.   SQL MAX() Syntax is as follows: Select MAX(column_name) From table_name;   Let us consider the below Students table: roll_no Name total_marks (out of 600) percentage grade 1 Ashok 392 65.33 B 2 Chaitali 454 75.67 A 3 Smriti 502 83.60 A 4 Kaushik 337 56.10 C   Now suppose based on the above

How to convert Uppercase to Lowercase in SQL?

To convert or change the value of a field from uppercase to lowercase, the LCASE() function is used.   SQL LCASE() Syntax is as follows: Select LCASE(column_name) From table_name;   Let us consider the below Students table: roll_no Name total_marks (out of 600) percentage grade 1 Ashok 392 65.33 B 2 Chaitali 454 75.67 A 3 Smriti 502 83.60 A 4 Kaushik 337 56.10 C   The following SQL statement