0
Assistance with using the SQRT function in SQL? Not sure if this is order or parenthesis? Issue with hypotenuse challenge!
Running into an issue with the hypotenuse challenge on the SQL course. I can get the square of both sides into 1 column, but I cannot get the SQRT function to work. This is what I have: SELECT side_a * side_a + side_b * side_b as side_c FROM triangle, SQRT (side_c); This code gets me error message on the SQRT function. If I remove the “SQRT(side_c)” I can get “side_c” to print. I’ve tried moving the SQRT function around but I can’t get it print. Any suggestions? Thanks
7 ответов
+ 7
Karsa9Fingers
Your query is wrong. If you write anything just after FROM it's mean you are pointing to a table so here SQRT(side_c) will be consider as table which is wrong.
So your query should look like this
SELECT SQRT(side_a * side_a + side_b * side_b)
AS "side_c" FROM triangle
+ 3
Кирилл Чернятин
Here side_c is column name. If you want to show result with different column name then you can do like that. You can put according to you.
+ 2
I Am AJ !
Thank you again sir! i had tried moving to the SQRT function around but couldn’t get it to work. I kept trying to create column “side_c” and then SQRT it, instead of adding SQRT to the equation. Thank you again.
+ 1
Кирилл Чернятин
For example: suppose you have a table Square with column side_a and you want to show result as side_a, area so what we can do here?
We can write our select query like
SELECT side_a as "side" , (side_a * side_a) AS "area" FROM Square
+ 1
I Am AJ !
Thank you for information ! Have a great day ! :).
0
I Am AJ !
Why is side_c in quotation marks ?
0
SELECT SQRT(side_a * side_a + side_b * side_b)
AS "side_c" FROM triangle