Ultimate Power
कभी-कभी आप क्वेरी के परिणामों को 'सेव' करना चाहेंगे ताकि डेटा पर आगे और काम कर सकें। आप ऐसा एक टemporary टेबल बनाकर कर सकते हैं, जो SQL Server के दोबारा शुरू होने तक डेटाबेस में बना रहता है। इस आख़िरी अभ्यास में, आप हर album से सबसे लंबा track चुनेंगे और उसे एक टemporary टेबल में जोड़ेंगे, जिसे आप क्वेरी के हिस्से के रूप में बनाएँगे।
यह अभ्यास पाठ्यक्रम का हिस्सा है
SQL Server परिचय
अभ्यास निर्देश
SELECTस्टेटमेंट के ज़रिए डेटा को#maxtracksनाम की टemporary टेबल में insert करें।albumकोartist_idके आधार परartistसे join करें, औरtrackकोalbum_idके आधार परalbumसे join करें।- अपनी नई टेबल से सभी कॉलम प्राप्त करने के लिए अंतिम
SELECTस्टेटमेंट चलाएँ.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
SELECT album.title AS album_title,
artist.name as artist,
MAX(track.milliseconds / (1000 * 60) % 60 ) AS max_track_length_mins
-- Name the temp table #maxtracks
INTO ___
FROM album
-- Join album to artist using artist_id
INNER JOIN artist ON album.artist_id = artist.artist_id
-- Join track to album using album_id
___
GROUP BY artist.artist_id, album.title, artist.name,album.album_id
-- Run the final SELECT query to retrieve the results from the temporary table
SELECT album_title, artist, max_track_length_mins
FROM #maxtracks
ORDER BY max_track_length_mins DESC, artist;