Informatics Practices
Write suitable SQL queries for the following :
(i) To calculate the exponent for 3 raised to the power of 4.
(ii) To display current date and time.
(iii) To round off the value -34.4567 to 2 decimal place.
(iv) To remove all the probable leading and trailing spaces from the column userid of the table named user.
(v) To display the length of the string ‘FIFA World Cup’.
SQL Queries
1 Like
Answer
(i)
SELECT POWER(3, 4);
Output
+-------------+
| POWER(3, 4) |
+-------------+
| 81 |
+-------------+
(ii)
SELECT NOW();
Output
+---------------------+
| NOW() |
+---------------------+
| 2024-05-21 12:20:03 |
+---------------------+
(iii)
SELECT ROUND(-34.4567, 2);
Output
+--------------------+
| ROUND(-34.4567, 2) |
+--------------------+
| -34.46 |
+--------------------+
(iv)
UPDATE user
SET userid = TRIM(userid);
(v)
SELECT LENGTH("FIFA World Cup");
Output
+--------------------------+
| LENGTH("FIFA WORLD CUP") |
+--------------------------+
| 14 |
+--------------------------+
Answered By
2 Likes
Related Questions
Preeti manages database in a blockchain start-up. For business purposes, she created a table named BLOCKCHAIN. Assist her by writing the following queries :
TABLE : BLOCKCHAIN
id user value hash transaction_date 1 Steve 900 ERTYU 2020-09-19 2 Meesha 145 @345r 2021-03-23 3 Nimisha 567 #wert5 2020-05-06 4 Pihu 678 %rtyu 2022-07-13 5 Kopal 768 rrt4% 2021-05-15 7 Palakshi 534 wer@3 2022-11-29 (i) Write a query to display the year of oldest transaction.
(ii) Write a query to display the month of most recent transaction.
(iii) Write a query to display all the transactions done in the month of May.
(iv) Write a query to count total number of transactions in the year 2022.
Ekam, a Data Analyst with a multinational brand has designed the DataFrame df that contains the four quarter’s sales data of different stores as shown below :
Store Qtr1 Qtr2 Qtr3 Qtr4 0 Store1 300 240 450 230 1 Store2 350 340 403 210 2 Store3 250 180 145 160 Answer the following questions :
(i) Predict the output of the following python statement :
(a) print(df.size) (b) print(df[1:3])
(ii) Delete the last row from the DataFrame.
(iii) Write Python statement to add a new column Total_Sales which is the addition of all the 4 quarter sales.
Or (Option for part (iii) only)
Write Python statement to export the DataFrame to a CSV file named data.csv stored at D: drive.
Kabir has created the following table named exam :
RegNo Name Subject Marks 1 Sanya Computer Science 198 2 Sanchay IP 100 3 Vinesh CS 90 4 Sneha IP 99 5 Akshita IP 100 Help him in writing SQL queries to perform the following tasks :
(i) Insert a new record in the table having following values : [6, 'Khushi', 'CS', 85]
(ii) To change the value "IP" to "Informatics Practices" in Subject column.
(iii) To remove the records of those students whose marks are less than 30.
(iv) To add a new column Grade of suitable datatype.
(v) To display records of "Informatics Practices" subject.
XYZ Media house campus is in Delhi and has 4 blocks named Z1, Z2, Z3 and Z4. The tables given below show the distance between different blocks and the number of computers in each block.
Block Z1 to Block Z2 80 metres Block Z1 to Block Z3 65 metres Block Z1 to Block Z4 90 metres Block Z2 to Block Z3 45 metres Block Z2 to Block Z4 120 metres Block Z3 to Block Z4 60 metres Number of computers installed at various buildings are as follows :
Block Number of computers Z1 135 Z2 290 Z3 180 Z4 195 The company is planning to form a network by joining these blocks.
(i) Out of the four blocks on campus, suggest the location of the server that will provide the best connectivity. Explain your response.
(ii) For very fast and efficient connections between various blocks within the campus, suggest a suitable topology and draw the same.
(iii) Suggest the placement of the following devices with justification
- Repeater
- Hub/Switch
(iv) VoIP technology is to be used which allows one to make voice calls using a broadband internet connection. Expand the term VoIP.
(v) The XYZ Media House intends to link its Mumbai and Delhi centers. Out of LAN, MAN, or WAN, what kind of network will be created? Justify your answer.