-
Notifications
You must be signed in to change notification settings - Fork 63
implemented army scenario #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shevawedeck
wants to merge
4
commits into
CPU-Code-School:main
Choose a base branch
from
Shevawedeck:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| use master | ||
| go | ||
| drop database if exists ArmyDB | ||
| go | ||
| create database ArmyDB | ||
| go | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use ArmyDB | ||
| go | ||
| drop table if exists dbo.Soldier | ||
| go | ||
| create table dbo.Soldier( | ||
| SoldierID int not null identity primary key, | ||
| FirstName varchar(25) not null constraint ck_Soldier_first_name_cannot_be_blank check(FirstName <> ''), | ||
| LastName varchar(25) not null constraint ck_Soldier_last_name_cannot_be_blank check(LastName <> ''), | ||
| SSN char(10) not null constraint ck_Soldier_SSN_cannot_exceed_10_digits_and_cannot_have_letters check(SSN like ('[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]')), | ||
| DOB date not null, | ||
| PlaceOfResidence varchar(40) not null constraint ck_Soldier_place_of_residence_cannot_be_blank check(PlaceOfResidence <> ''), | ||
| DateEnlisted date not null | ||
| constraint ck_Soldier_date_enlisted_cannot_be_a_future_date check(DateEnlisted <= getdate()), | ||
| ServiceUnit varchar(15) not null | ||
| constraint ck_Soldier_service_unit_must_be_air_force_navy_or_ground_force check(ServiceUnit in('Air Force', 'Ground Force', 'Navy')), | ||
| Rank varchar(90) not null constraint ck_Soldier_rank_cannot_be_blank check(Rank <> ''), | ||
| IQLevel int not null constraint ck_Soldier_IQ_level_must_be_greater_than_0 check(IQLevel > 0), | ||
| constraint ck_Soldier_must_be_at_least_17_when_enlisted check(datediff(year, DOB, DateEnlisted) >= 17) | ||
| ) | ||
| go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| use ArmyDB | ||
| go | ||
|
|
||
| delete Soldier | ||
| insert Soldier(FirstName, LastName, SSN, DOB, PlaceOfResidence, DateEnlisted, ServiceUnit, Rank, IQLevel) | ||
| select 'Ron', 'Aviad', '54876373-2', '01/01/2000', 'Caesarea', '01/03/2021', 'Air Force', 'sergeant', 95 | ||
| union select 'Shachar', 'Dotan', '85274136-9', '08/16/2001', 'Jerusalem', '10/01/2020', 'Navy', 'lieutenant colonel', 111 | ||
| union select 'Osher', 'Sharon', '95135778-2', '05/04/1996', 'Tel-Aviv', '04/01/2017', 'Ground Force', 'sergeant', 79 | ||
| union select 'Yoni', 'Tamari', '24863570-5', '11/23/1999', 'Jerusalem', '12/01/2018', 'Air Force', 'lieutenant general', 139 | ||
| union select 'Shai', 'Ben Zeev', '93185378-1', '09/13/2001', 'Netanya', '01/01/2020', 'Air Force', 'sergeant', 120 | ||
| union select 'Dory', 'Lavie', '16834952-7', '10/28/2004', 'Haifa', '12/01/2021', 'Navy', 'brigadier general', 118 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
|
|
||
| --1) Show a list of all soldiers with all details sorted by IQ level from high to low. | ||
| select * | ||
| from Soldier s | ||
| order by s.IQLevel desc | ||
|
|
||
| --2) I need a list of all soldiers sorted by age at enlistment from high to low. Do not include columns that are not relevant to this list. | ||
| select AgeAtEnlistment = datediff(year, s.DOB, s.DateEnlisted), s.LastName | ||
| from Soldier s | ||
| order by AgeAtEnlistment desc | ||
|
|
||
| /* 3) Following an upward trend in recruitment since the outbreak of Covid, I need data on recruitment between the years 2017-2019 compared to the years 2020-2022. | ||
| The format should be as follows :Year Range (2017-2019/2020-2022), First Name Last Name - SSN (date of enlistment), service unit. | ||
| (This should be done by using a union select and adding a literal column for year range.) */ | ||
| select YearRange = | ||
| case | ||
| when year(s.DateEnlisted) between 2017 and 2019 then '2017-2019' | ||
| when year(s.DateEnlisted) between 2020 and 2022 then '2020-2022' | ||
| end | ||
| , SoldierInfo = concat(s.FirstName, ' ', s.LastName, ' - ', s.SSN, ' (', s.DateEnlisted, '), ',s.ServiceUnit) | ||
| from Soldier s | ||
| --4) I need to know what the average IQ level is for soldiers per service unit. | ||
| select AvgIQ = avg(s.IQLevel), s.ServiceUnit | ||
| from Soldier s | ||
| group by s.ServiceUnit | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The report specifies how to do it. But it's ok