mikeyworx

#2 Decimal into whole number

Jun 25th, 2023 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.96 KB | Source Code | 0 0
  1. -- JOHN MICHAEL GONZALES
  2. -- BSIT CUBAO2
  3. -- #2 ACTIVITY MYSQL
  4. -- DECIMAL INTO WHOLE NUMBER
  5.  
  6. -- Create the database
  7. CREATE DATABASE nba_decimal;
  8.  
  9. -- Switch to the created database
  10. USE nba_decimal;
  11.  
  12. -- Create the table
  13. CREATE TABLE nuggets (
  14.     player_number INT,
  15.     player_name VARCHAR(50),
  16.     rebounds DECIMAL(10, 2),
  17.     assists DECIMAL(10, 2),
  18.     points DECIMAL(10, 2)
  19. );
  20.  
  21. -- Insert player data into the table
  22. INSERT INTO nuggets (player_number, player_name, rebounds, assists, points)
  23. VALUES
  24.     (1, 'X', 0.00, 0.00, 0.00),
  25.     (2, 'X', 0.00, 0.00, 0.00),
  26.     (3, 'X', 0.00, 0.00, 0.00),
  27.     (4, 'X', 0.00, 0.00, 0.00),
  28.     (5, 'X', 0.00, 0.00, 0.00);
  29.  
  30. -- Display the table with both decimal and converted whole number points
  31. SELECT player_name,
  32.     rebounds, CAST(rebounds AS UNSIGNED) AS Conveted_Rebounds,
  33.     assists, CAST(assists AS UNSIGNED) AS Conveted_Assists,
  34.     points, CAST(points AS UNSIGNED) AS Conveted_Points
  35. FROM nuggets;
Advertisement
Add Comment
Please, Sign In to add comment