create files for excercise abo_view
This commit is contained in:
parent
795199060e
commit
a1df39be3a
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# SQL Server Management Studio Solution File, Format Version 13.00
|
||||||
|
VisualStudioVersion = 14.0.23107.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "abo_view", "abo_view\abo_view.ssmssqlproj", "{7DAC2196-6434-46C5-9531-7F7E89CE3C37}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Default|Default = Default|Default
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{7DAC2196-6434-46C5-9531-7F7E89CE3C37}.Default|Default.ActiveCfg = Default
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="SqlWorkbenchSqlProject">
|
||||||
|
<Items>
|
||||||
|
<LogicalFolder Name="Connections" Type="2" />
|
||||||
|
<LogicalFolder Name="Queries" Type="0" />
|
||||||
|
<LogicalFolder Name="Miscellaneous" Type="3" />
|
||||||
|
|
||||||
|
</Items>
|
||||||
|
</SqlWorkbenchSqlProject>
|
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
-- A1.1 create student view
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
create view mitglied_student_v(Anr, Nachn, Vorn, Ort)
|
||||||
|
as
|
||||||
|
select a.anrede,
|
||||||
|
m.mitglied_name,
|
||||||
|
m.mitglied_vorname,
|
||||||
|
o.ortsname
|
||||||
|
from mitglied m
|
||||||
|
inner join anrede a
|
||||||
|
on m.anrede_id = a.anrede_id
|
||||||
|
inner join ort o
|
||||||
|
on m.ort_id =o.ort_id
|
||||||
|
inner join abo
|
||||||
|
on m.abo_id = abo.abo_id
|
||||||
|
where abo.abo_name = 'Student'
|
||||||
|
|
||||||
|
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
select * from mitglied_student_v;
|
||||||
|
go
|
||||||
|
|
||||||
|
-- drop the view
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
drop view mitglied_student_v;
|
||||||
|
|
||||||
|
-- A1.2 create Zürich Mitglied view
|
||||||
|
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
create view mitglied_zuerich_v(Anr, Nachn, Vorn, Aboart, PLZ, Ort)
|
||||||
|
as
|
||||||
|
select a.anrede,
|
||||||
|
m.mitglied_name,
|
||||||
|
m.mitglied_vorname,
|
||||||
|
abo.abo_name,
|
||||||
|
o.postleizahl,
|
||||||
|
o.ortsname
|
||||||
|
from mitglied m
|
||||||
|
inner join anrede a
|
||||||
|
on m.anrede_id = a.anrede_id
|
||||||
|
inner join ort o
|
||||||
|
on m.ort_id =o.ort_id
|
||||||
|
inner join abo
|
||||||
|
on m.abo_id = abo.abo_id
|
||||||
|
where o.ortsname = 'Zürich';
|
||||||
|
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
select * from mitglied_zuerich_v;
|
||||||
|
|
||||||
|
-- drop the view
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
drop view mitglied_zuerich_v;
|
||||||
|
|
||||||
|
|
||||||
|
-- A1.3 create view Mitglieder/Aboart
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
create view mitglied_aboart_v(AboArt, 'Anzahl Mitglieder')
|
||||||
|
as select
|
||||||
|
abo.aboname,
|
||||||
|
|
||||||
|
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
select * from mitglied_aboart_v;
|
||||||
|
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
drop view mitglied_aboart_v;
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- drop the view
|
||||||
|
use Abo;
|
||||||
|
go
|
||||||
|
|
||||||
|
drop view mitglied_student_v;
|
Reference in New Issue