The Most Viewed Videos of all Time
Welcome
Login / Register

hacker rank sql server questions | SQL Server |SQL Interview Preparation | Part 46

Thanks! Share it with your friends!

URL

You disliked this video. Thanks for the feedback!

Sorry, only registred users can create playlists.
URL


Added by Admin in Top 10
68 Views

Description

#ssu #ssunitech
#ManhattanDistance
#Euclideandistance
Hacker Rank

Find Us On YouTube- "Subscribe Channel to watch Database related videos" https://www.youtube.com/channel/UCZA_5vGtSpZu86VBDdSnSag

For SQL Quiz-
https://www.youtube.com/watch?v=IaDXFyZSo7Y&list=PLNRxk1s77zfitFbrlRICVDgVodMr25mYl

Find Us On FaceBook-
https://www.facebook.com/SS-Unitech-187705388674384/

---QUESTION--1
IF EXISTS (SELECT 1 FROM SYS.tables WHERE NAME='STATION')
BEGIN
DROP TABLE STATION
END

CREATE TABLE STATION
(
ID INT,
CITY VARCHAR(21),
STATE VARCHAR(10),
LAT_N NUMERIC(14,8),
LONG_W NUMERIC(14,8)
)
INSERT STATION VALUES (1,'Noida','UP',1.025,2.365789),(2,'Kanpur','UP',5.36987,5.369874),
(2,'Unnao','UP',1.12567,6.354789),(4,'Pune','M',2.36548,3.012548)

SELECT CAST((MAX(LAT_N)-MIN(LAT_N))+(MAX(LONG_W)-MIN(LONG_W)) AS NUMERIC(14,4))
FROM STATION

---QUESTION--2

IF EXISTS (SELECT 1 FROM SYS.TABLES WHERE NAME='STATION')
BEGIN
DROP TABLE STATION
END

CREATE TABLE STATION
(
ID INT,
CITY VARCHAR(21),
STATE VARCHAR(10),
LAT_N NUMERIC(14,8),
LONG_W NUMERIC(14,8)
)
INSERT STATION VALUES (1,'Noida','UP',1.025,2.365789),(2,'Kanpur','UP',5.36987,5.369874),
(2,'Unnao','UP',1.12567,6.354789),(4,'Pune','M',2.36548,3.012548)

SELECT CAST(SQRT((SQUARE(MAX(LAT_N)-MIN(LAT_N)))+SQUARE((MAX(LONG_W)-MIN(LONG_W)))) AS NUMERIC(14,4))
FROM STATION

Post your comment

Comments

Be the first to comment
RSS