0% found this document useful (0 votes)
3 views

Assignment_4

Uploaded by

lizzmc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment_4

Uploaded by

lizzmc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--CTAS( go through CREATE TABLE AS SELECT any open source ) example: youtube

create table youtube_impressions as


select video_title, video_views, video_likes, video_summary from youtube_data
where video_views is not null;

--Insert into select statement


insert into youtube_impressions (video_title, video_views, video_likes,
video_summary)
select video_title, video_views, video_likes, video_summary
from yt_old_data
where video_views is not null;

--Case statement
select case when video_views > 10000 then 'high' when video_views between 5000 and
10000 then 'medium' else 'low' end as like_counts
from youtube_impressions;

--Creating backup table and restore


create table youtube_backback as
select * from youtube_impressions;

create table youtube_restore as


select * from youtube_backup;

--Insert all the names(employee name, spouse name, father name) from one table into
a single column

select employee_name as name from table1


union
select spouse_name as name from table1
union
select father_name as name from table1

You might also like