[prog] SQL - MSSQL2020. 12. 18. 09:21

참고 : docs.microsoft.com/ko-kr/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15

 

 

-- 실행 1
select max(yearlyIncome) as 최고수입
from   DimCustomer (nolock)

/***********************
실행 1 의 결과 
   최고수입
-----------
1  170000.00
***********************/

----------------------------
-- 실행 2
declare @yIncome float
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

----------------------------
-- 실행 3
declare @yIncome numeric
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

----------------------------
-- 실행 4
declare @yIncome decimal(10, 2)
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

----------------------------
-- 실행 5
declare @yIncome numeric(10, 2)
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

 

 

결과 2, 3
   최고수입
-------------
1  170000

--------------------------------------------

결과 4, 5
   최고수입
-------------
1  170000.00

 

Posted by dawnawaker

The New York Times
U.K. Approves Pfizer Coronavirus Vaccine, a First in the West

By Benjamin Mueller
Published Dec. 2, 2020
Updated Dec. 8, 2020, 8:35 a.m. ET

www.nytimes.com/2020/12/02/world/europe/pfizer-coronavirus-vaccine-approved-uk.html

 

U.K. Approves Pfizer Coronavirus Vaccine, a First in the West

The emergency approval, ahead of the United States and the European Union, clears the way for Britain to begin mass inoculations. “Help is on its way,” one official said.

www.nytimes.com

개인적 용도이며 잘못된 해석 있을 수 있음
-------------------------------------
LONDON — Britain gave emergency authorization on Wednesday to Pfizer’s coronavirus vaccine, leaping ahead of the United States to become the first Western country to allow mass inoculations against a disease that has killed more than 1.4 million people worldwide.

inoculations [inὰkjuléiʃən]  접중, 주입

수요일 영국은 파이자(미국 제약사)의 코로나 바이러스 승인에 대한 긴급 승인을 내주었는데, 이는 미국을 뛰어넘어 (파이자 백신을 승인한) 첫 서구권 국가가 된 것이며, 전 세계적으로 140만명 이상의 목숨을 앗아간 질병에 대한 많은 이들의 접종을 가능하게 했다.

The decision cleared the way for a vaccination campaign with little precedent in modern medicine, encompassing not only ultracold dry ice but also a crusade against anti-vaccine misinformation.

이 결정은 현대 역사에서 그 전례를 찾아보기 어려운 예방접종 캠페인을 할 수 있도록 했는데, (수송및 보관을 위한) 엄청나게 차가운 드라이아이스 뿐만이 아니라 잘못된 백신거부 정보에 대한 치열한 싸움도 예상된다.

encompass  둘러싸다, 포함(포위)하다

Britain’s beating the United States to authorization — on a vaccine codeveloped by an American company, no less — intensified pressure on U.S. regulators, who are under fire from the White House for not moving faster to get doses to people. But it also fueled concerns that Britain was acting in haste for political reasons or trying to muscle its way to the front of the line for deliveries.

영국은 미국이 -미국 회사에 의해 공동개발된(이 백신은 미국 파이자사와 독일의 바이오앤테크사 공동 개발로 만들어졌다)- 이 백신을 승인하는 것보다 더 빨리 승인했고, 이는 미국 규제위원회에게는 압박이 되고 있는 상황인데, 미국 규제위원회는 현재 사람들에게 접종할 수 있도록 더 빨리 움직이고 있지 않다고 백악관을 부터 비난을 받고 있다.
하지만, 이는 또한 영국이 정치적 이유로 서두르고 있거나, (백신) 배송을 빨리 받으려고 무리하게 시도하고 있다는 염려에 기름을 붓고 있다.

intensify  격렬하게 하다
under fire  비난받다, 집중포화를 당하다

European regulators on Wednesday cast doubt on the rigor of Britain’s review and said that the authorization was limited to specific batches of the vaccine, a claim that Pfizer denied and British officials did not address.

수요일, 유럽의 규제위원회들은 영국이 제대로 조사했는지에 대해서 의문을 던지며, 그 승인은 그 백신에 대한 특별한 접종에만 제한되었다고 말했는데, 파이자사는 이를 부인했으며, 영국 관리들은 언급하지 않았다.

rigor [rígər]  엄격함, 어려움, 고됨
batch  1회분, 한 묶음, 한 다발

Britain’s move provoked a spirited debate among American scientists about whether U.S. regulators, who are known to be unusually meticulous, could afford to hold off any longer on authorizing a vaccine against a virus that is claiming more than 10,000 lives a day worldwide.

영국의 이러한 움직임은 미국 과학자들 사이에 다음과 같은 열띤 논쟁을 불러일아켰다 - 특별히 주의 깊은 것으로 알려져있는 미국의 규제 위원회가 전세계적으로 하루 10,000 명 이상의 목숨을 앗아가고 있는 바이러스에 대한 백신 승인을 더이상 유보하고 있을 수 있을 것이가.

provoke  자극하다, 유발하다, 촉발시키다
meticulous [mətíkjuləs] 주의 깊은, 꼼꼼하게 신경쓰는

American regulators have argued that they lag behind — if only by a matter of days — because they are virtually alone in reanalyzing thousands of pages of raw data from vaccine trials before approval. Backers of that approach say it is the only way to minimize unintended damage, in lives and in public trust, from vaccines not working.

미국의 규제위원회는 그들이 -설령 단 며칠 차이라고 하더라도- 그들이 뒤쳐져있는 상태이며 그 이유는 백신에 대한 승인 이전에 수천페이지에 관한 자료들을 재분석하는 실제로 유일한 기관이기 때문이라고 주장했다. 
이러한 주장에 대한 지지자들은 이것이 제대로 효과를 내지 못하는 백신때문에 생명이나 공공의 신뢰상에 있어서의 의도치 못한 손상을 최소화 시키는 유일한 방법이라고 주장한다.

British and European regulators lean more heavily on the companies’ own analyses, auditing their figures occasionally but otherwise grounding their decisions on vaccine makers’ reports. While the more cautious American approach can be valuable, some scientists said the Europeans subject vaccine makers to considerable scrutiny, and it is imperative to move quickly to curb the suffering wrought by the pandemic.

영국과 유럽의 규제위원회는 보다 더 그 회사(파이자) 자체의 분석을 믿고 있는데, 가끔씩은 제조사들이 보고하는 수치를 면밀히 조사하지만, 그렇지 않는 경우, 그들의 결정을 백신 제조사의 보고에 의존한다.
일부 과학자들은 이렇게 말한다 - 보다 더 신중한 미국식 접근방법이 더 좋겠지만, 유럽인들은 백신제조사들을 좀 더 면밀하게 조사하여야 하고, 현재의 전 세계적인 유행병의 상황때문에 빚어진 고통을 줄이기 위해서는 빠른 움직임이 필수적이다.

audit [ɔ́ːdit]  회계감사, 철저한 검사
subject A to B  A를 B에 종속시키다, 복속시키다, 맡기다
scrutiny [skrúːtəni]  정밀 조사
imperative  명령의, 명령조의, 긴급한, 필수의
curb  보도의 연석, 억제하다, 억누르다
wrought [rɔːt]  (상황, 변화등을) 가져오다, 불러오다 / 만들어진, 형체가 갖추어진

“When you say it’s OK to wait another week or two, you’re saying it’s OK that many thousands of people are going to die,” said Dr. Walid F. Gellad, who leads the Center for Pharmaceutical Policy and Prescribing at the University of Pittsburgh.

No country until Wednesday had authorized a fully tested coronavirus vaccine; Russia and China approved vaccines without waiting for large-scale efficacy tests.

“Help is on its way with this vaccine — and we can now say that with certainty, rather than with all the caveats,” the British health secretary, Matt Hancock, said Wednesday.

While the go-ahead bodes well for Britain, which broke from the European Union’s regulatory orbit to approve the vaccine early, it will have no effect on the distribution of the hundreds of millions of doses that the United States and other wealthy countries have procured in prepaid contracts.

It also offers little relief to poorer countries that could not afford to buy supplies in advance and may struggle to pay for both the vaccines and the exceptional demands of distributing them.

Roughly 800,000 doses of the Pfizer vaccine, developed with BioNTech, a smaller German firm, were being packaged at the company’s Belgian manufacturing plant on Wednesday for shipment to Britain. How and when they will arrive is a secret for security reasons, the company said.

The complicated logistics of moving, defrosting and preparing the vaccine meant it was going to be given only at 50 British hospitals to begin with. The vaccine must be transported at South Pole-like temperatures, and in trays of 975 doses.

First to be vaccinated will be doctors and nurses in the country’s National Health Service, along with nursing home workers and people 80 and over with previously scheduled doctors’ appointments. A government advisory committee has suggested that older or more vulnerable health workers, and doctors and nurses who work with fragile patients, would be among the first in line.

But the government has not said when other employees of the National Health Service would be eligible for vaccines. Essential workers, like teachers, transport workers and first responders, would not be vaccinated until after people 50 and over and those with underlying health problems received shots.

The advisory committee plans had made nursing home residents a top priority, but they will have to wait until the government begins distributing vaccines beyond hospitals. Pfizer and BioNTech have suggested that is possible, given that the vaccine can be stored for five days in a normal refrigerator.

Eventually, people will get their shots in mass vaccination centers being set up by the military at soccer stadiums and racecourses, or at doctors’ offices and pharmacies.

“We’ve been waiting and hoping for the day when the searchlights of science would pick out our invisible enemy, and give us the power to stop that enemy from making us ill,” Prime Mister Boris Johnson said on Wednesday. “And now the scientists have done it.”

For Britain, which has suffered one of Europe’s highest per capita death tolls from the virus, the decision by its drug regulator was the latest evidence of a vaccination strategy that has been the most aggressive in the West.

Britain remains under the authority of the European Union’s drug regulator until it consummates its split from the bloc on Dec. 31. But the government recently strengthened an old law that allows it to step out from under the bloc’s regulatory umbrella in public health emergencies. That allowed it to fast-track a review of the Pfizer vaccine, which was 95 percent effective in a late-stage clinical trial.

Britain had pre-ordered 40 million doses of the vaccine and 315 million doses of competing vaccines, spreading its bets to assure it can inoculate the country’s 67 million people.

British ministers cast the speed of the Pfizer approval as an early example of the new flexibility the country will have once it fully untethers itself from European regulation. Yet Brexit has also exacted costs, starving Britain’s drug regulator of money it used to draw from contracts with the European Union.

British regulators are also vetting a vaccine developed by the University of Oxford and AstraZeneca, a British-Swedish company. It is cheaper and easier to store than Pfizer’s, so much of the world could rely on it, but its regulatory path forward in the United States is unclear after scientists and industry analysts questioned promising early results.

The chemistry underlying Pfizer’s vaccine had never before produced an approved shot, but scientists have experimented with it for years, testing vaccines that did not make it to market. In order to coax cells to make a viral protein, called a spike, and elicit an immune response, this class of vaccine delivers genetic instructions, known as messenger RNA, encased in tiny fat globules.

BioNTech made a prophetic bet on the technology and joined forces with Pfizer, one of the world’s largest drug companies; they ended up delivering stunning results, on a timeline that was unheard-of before this year.

The U.S. Food and Drug Administration plans to decide on emergency authorization for the Pfizer vaccine shortly after a meeting of an advisory panel on Dec. 10. American officials have said vaccinations could begin within 24 hours after approval.

Another American company, Moderna, and the National Institutes of Health have also developed a messenger RNA vaccine that has proved effective in large trials. The F.D.A. will consider their application for emergency authorization shortly after Pfizer’s.

The European Medicines Agency, which regulates vaccines across the European Union, is expected to make a decision about the Pfizer vaccine later in December.

Pfizer has said it expects to be able to produce up to 50 million doses this year, about half of them going to the United States. Since each person needs two doses, a month apart, up to 25 million people worldwide could begin vaccination before 2021.

The United States has bought 100 million doses in advance from Pfizer, and the European Union 200 million doses.

The approval arrived at a perilous moment in the pandemic in Britain, where the virus has killed nearly 70,000 people, and hundreds more die each day. A third of England’s hospital systems were caring for more Covid-19 patients in recent weeks than at the height of the first wave in the spring.

A monthlong shutdown of restaurants and pubs has stanched the spread of the virus, but that is being replaced by a less stringent system of localized restrictions, with allowances for Christmastime travel that scientists fear will seed another uptick in infections.

In a clinical trial, the Pfizer-BioNTech vaccine proved highly effective among older adults, who are more vulnerable to developing severe Covid-19 and who do not respond strongly to some types of vaccines. It caused no serious side effects.

As vaccines become widely available, the scientific feat of developing them will give way to the social and political problem of convincing people to take them. In Britain, the source of some of the most virulent modern disinformation about vaccines, just over half of people have said in surveys they would definitely accept an inoculation.

Safety concerns have been accentuated by the speed of vaccine testing and approval, despite Britain’s regulators saying repeatedly they were not taking shortcuts.

Beyond those challenges, manufacturers will quickly need to eventually make billions of doses and move them to hospitals, clinics and pharmacies.

The Pfizer vaccine makes this effort especially complex. It has to be stored at around minus 70 degrees Celsius (minus 94 Fahrenheit) until shortly before injection, requiring transportation in boxes stuffed with dry ice.

Matina Stevis-Gridneff contributed reporting from Brussels, Katie Thomas from Chicago and Rebecca Robbins from Bellingham, Wash.

Posted by dawnawaker

from Yahoo News

[원문링크] news.yahoo.com/republican-us-judges-choose-the-constitution-over-trump-as-electionfraud-cases-keep-failing-211255403.html

 

Republican U.S. judges choose Constitution over Trump as election fraud cases keep failing

Federal judges appointed by Republican and Democratic presidents alike have struck down the Trump campaign’s allegations of widespread voter fraud in every case on which they have ruled, according to a Yahoo News review of post-election federal complaint

news.yahoo.com

[참고] 이 글의 원문은 '야후 뉴스' 이며, 단지 개인적인 영어공부를 위한 해석이므로, 해석에 잘못된 부분이 있을 수 있습니다.

--------------------------------------

 

Republican U.S. judges choose Constitution over Trump as election fraud cases keep failing

공화당 판사들이 트럼프 보다는 헌법을 선택하면서 선거조작관련 건들이 계속 기각되고 있다.

 

Crystal Hill

·Reporter

Fri, December 4, 2020, 6:12 AM GMT+9

 

If President Trump and his campaign’s legal team thought conservative-leaning federal judges would be especially sympathetic to their allegations of election fraud, the record is showing they were mistaken.

 

트럼프 대통령과 그의 선거운동 법무팀이 보수성향의 연방 판사들이 그들(트럼프와 법무팀)이 주장하고 있는 선거조작 혐의에 특히 긍정적으로 보아줄 것이라고 생각했다면 실수했다는 것이 기록으로 보여진다. 

allegation : 의혹, 혐의

 

Judges appointed by Republican and Democratic presidents alike have struck down the campaign’s allegations of voter fraud in every case on which they have ruled, according to a Yahoo News review of post-election federal complaints, active and closed, that were brought directly by the Trump campaign or by attorneys who are independently seeking to invalidate the results of the election in battleground states.

 

진행중이거나 이미 진행이 끝난 대선후 연방정부에 올라온 고발건들에 대한 야후 뉴스의 검토결과, 공화당과 민주당 대통령들에 의해 지명되어진 판사들은 모두 그들이 결정내린 건들 모두에 대한 대선 투표자 조작혐의를 기각시켰다 라고 되어있는데, 이런 고발건들은 트럼프 대선진영이나 또는 격전지가 되었던 주들의 선거를 무효화 시키고자 독립적으로 활동하는 지방검사들이 직접 제출한 것이다. 

attorney : 지방검사

 

The review found that none of the nine federal judges who were appointed by Republican presidents or identified as Republicans before their confirmation (including a three-person appellate panel) assigned to seven of the 13 total cases, as of Dec. 3, ruled in favor of the campaign’s election fraud allegations. Lawsuits were filed in Pennsylvania, Michigan, Georgia, Nevada, Wisconsin and Arizona.

 

조사에 따르면, 총 13건 중 7건에 할당된, 공화당 대통령에 의해 임명되거나 스스로 확인해주기 이전에(3인 상고위원회도 포함해서) 공화당쪽으로 밝혀진 연방판사 9명 중 그 어느 누구도 12월 3일 현재 대선의 선거 조작혐의에 손을 들어주지 않았다.   
펜실베니아, 미시간, 조지아, 네바다, 윈스콘신, 아리조나 주에서 (이런 선거조작) 소송이 제기되었다. 

appellate  상소의, 상고의 
rule  지배하다, 판결을 내리다 
rule in favor of A : A 에 우호적으로 판결하다 

 

Although federal judges are not expected to openly support a partisan agenda, Trump has often boasted about the number of conservative judges he has appointed and implied he expected them to rule in his favor.

 

연방 판사들이 정당의 정책을 공개적으로 지지할거라 생각되지는 않는다 하더라도, 트럼프는 그가 임명한 보수성향 판사들의 숫자에 대해 종종 자랑했고, 그들이 자기 편에서 판결내려 줄 것이라는 속내를 비쳐왔다.

partisan [pάːrtizən] 당파적인, 정당에 따른 (party : 정당)
boast [boust] 자랑하다, 뻐기듯이 말하다

 

On substantive legal questions many of them have, but the electoral process, which goes to the heart of American democracy, is a different story. The campaign’s inability to gain traction with conservative judges is telling.

 

그들 중 많은 이들이 가진 실질적인 법적 문제들에 대해서, 선거과정 만은 - 이 부분은 미국식 민주주의의 핵심을 건드리는 부분이다 - 다른 이야기이다.  트럼프 대선팀이 보수성향 판사들에게서 힘을 얻지 못하고 있다는 것이다.

substantive [sΛbstəntiv] 독립적인, 실질적인, 상당한
electoral  선거의
traction  견인, 수축, 마찰
gain traction 견인력을 얻다, 일이 수월하게 잘 진행되다.

 

“Despite the narrative that Republicans have been marching in lockstep with President Trump and willing to say anything to further his agenda, there have been federal judges who were appointed by Trump, as well as state and local Republican officials, who, when faced with their duty and the reality in front of them, have done the right thing,” Renato Mariotti, a former federal prosecutor in Chicago and legal analyst, told Yahoo News.

 

예전에 시카고에서 연방 검사를 지냈던 레나토 모리오띠는 야후 뉴스팀에 이렇게 말했다 - "공화당쪽 사람들이 트럼프와 보조를 맞춰왔고 또 그 어떤 얘기도 한다고 하지만, 트럼프나 주정부 또는 지역의 공화당 관리들에 의해 임명되어졌어도 막상 그들의 의무와 현실에 맞닥뜨렸을때는 옳은 일을 선택하는 연방 판사들이 있어왔다."

lockstep  딱딱 맞춘 보조, 발걸음, 엄밀한 진행방식

 

In Pennsylvania, the responses have been particularly scathing. A recent opinion authored by Stephanos Bibas, a Trump-appointed judge in the U.S. Court of Appeals for the Third Circuit and an apparent member of the Federalist Society, a conservative judicial organization, sharply criticized the campaign’s bid to prevent Pennsylvania officials from certifying the election results, which has since occurred in the state.

 

이런 현상은 펜실베니아주에서 특히 뚜렸했다.  트럼프가 임명한 제3 순회 항소법원 판사이자 보수성향 사법조직인 '연방주의 모임'의 일원인 스테파노스 바이바스는 자신의 의견에서 펜실베니아주 관리들이 선거결과를 확인하지 못하게 하려는 시도를 날카롭게 비난했다.

scathing [skéiðiŋ]  통렬한, 봐주지않는
bid  입찰, 출마, 노력, 시도
certify  증명하다, 보증하다

 

Bibas, in his opinion rendered Nov. 27, seemed to pinpoint the central flaw of the Trump campaign’s overall crusade, noting that its attorneys are making multiple conclusory allegations, such as the accusation that county boards conspired to exclude Republican poll watchers from the ballot-counting process, but aren’t presenting sufficient facts to back up those claims.

 

11월 27일 밝힌 의견에서 바이바스는 전반적인 트럼프의 대선과정의 주요한 실수를 정확히 꼬집어 말하려는 듯이 다음과 같이 말했다 - 펜실베니아 지방검사들이 몇가지 결정적인 의혹을 만들고 있다는 것인데, 예를 들면 지역 의회들이 공모해서 표확인 과정에서 공화당 선거 감시원들을 배제했다는 것인데, 그러한 주장을 뒷받침 할만한 충분한 사실을 제공하고 있지 않다는 것이다.

render  :  1) = make -를 만들다, -하게 하다  2) = give
pinpoint  :  …의 위치를 정확히 나타내다; [원인·본질을] 정확히 지적[설명]하다.
crusade  :  십자군, 성전 - 여기서는 치열한 대선과정을 표현
conclusory  :  결정적인
accusation  :  비난, 고발, 고소, 기소
conspire  :  공모하다, 음모를 꾸미다

 

He also pointed out that Rudy Giuliani, Trump’s personal lawyer, said during an oral argument that the campaign isn’t alleging fraud.

“Charges of unfairness are serious,” Bibas said. “But calling an election unfair does not make it so. Charges require specific allegations and then proof. We have neither here.”

Bibas’s opinion was cosigned by two other circuit judges: Chief Judge D. Brooks Smith, who was appointed by President George W. Bush in 2001, and Judge Michael A. Chagares, who was also nominated by Bush, in 2006.

“I think that that decision punctuates what Chief Justice [John] Roberts (of the U.S. Supreme Court) said about there not being Bush judges or Obama judges or Trump judges,” Mariotti told Yahoo News. “The fact that you have scathing opinions from judges like Judge Bibas says more about the strength of the legal cases being brought by the Trump campaign and their allies than it does about those judges, because it’s not hard to see on the face of these filings that they’re deficient.”

 

Federal judges at all levels have lifetime tenure and can be removed only by impeachment, an extremely rare step generally reserved for instances of outright corruption or malfeasance. The Framers made that rule precisely to insulate the federal judiciary from partisan political pressures.

The circuit ruling was on an appeal of a lawsuit first filed in the Middle District of Pennsylvania on Nov. 9, court records show.

In that court, Judge Matthew Brann, who was appointed by President Barack Obama in 2012 but is a Republican and a member of the Federalist Society, according to his Senate questionnaire, on Nov. 21 dismissed the complaint with prejudice, meaning that the campaign can’t file that complaint again on the same basis.

Brann took the campaign to task for what he described as “strained legal arguments without merit” and called one of its claims “Frankenstein’s Monster” — an argument that has been “haphazardly stitched together from two distinct theories in an attempt to avoid controlling precedent,” per the opinion.

After Brann’s decision, the Trump campaign released a statement that oddly seemed to welcome the dismissal.

“Today’s decision turns out to help us in our strategy to get expeditiously to the U.S. Supreme Court,” the campaign said. “Although we fully disagree with this opinion, we’re thankful to the Obama-appointed judge for making this anticipated decision quickly, rather than simply trying to run out the clock. We will be seeking an expedited appeal to the Third Circuit.”

Then, after Bibas’s opinion, campaign attorney Jenna Ellis issued a statement on Twitter from her and Giuliani claiming that the “activist judicial machinery in Pennsylvania continues to cover up the allegations of massive fraud.” Ellis has not responded to emailed questions from Yahoo News.

 

In Georgia, where attorneys including Trump supporter Lin Wood filed a suit on Nov. 25 alleging a voting-machine conspiracy linked to Venezuela, U.S. Northern District Judge Timothy C. Batten denied a request from attorneys to prohibit the defendants — Gov. Brian Kemp and Secretary of State Brad Raffensperger — from destroying or altering data on any Dominion voting machine in Cobb, Gwinnett and Cherokee counties, according to a transcript from a Nov. 29 hearing shared by Democracy Docket.

Batten was nominated by Bush and confirmed in 2006.

Attorney Sidney Powell, a vehement Trump supporter from whom the campaign has publicly distanced itself, filed a notice on Dec. 1 indicating that she plans to appeal Batten’s decision to the 11th Circuit, court documents show.

Batten and his aforementioned four colleagues are all conservative and/or Republican-appointed federal judges who’ve denied requests from the campaign and its allies to block certification or invalidate election results based on flimsy allegations of fraud. The other four judges, of nine total, presided over cases that were resolved by agreement or were voluntarily withdrawn by the plaintiffs.

The Trump campaign, which has brought most of its roughly three dozen cases at the county or state level, has indicated it wants to bring a case before the U.S. Supreme Court, which has a conservative majority. A tally by Yahoo News of federal cases includes a petition to the Supreme Court to review a state case brought by U.S. Rep. Mike Kelly, R-Pa., that sought to block officials from certifying the state’s election results. The Pennsylvania Supreme Court vacated an order from a lower court that had prohibited state officials from taking any further action regarding the certification of the results.

 

 

In a statement issued in support of the petition, Sen. Ted Cruz, R-Texas, called the state’s high court a “partisan Democrat Supreme Court” that has issued “decisions that reflect their political and ideological biases.” Of the court’s seven judges, two are Republicans.

Legal experts say it’s unlikely that the nation’s highest court will accept the case.

“The [plaintiff] wants an order from the U.S. Supreme Court nullifying the effect of the certification of the electors,” Richard Hasen, an election law professor at the University of California, Irvine, wrote in his election law blog. “It is not clear that this kind of remedy is even available. But I do not expect this case to go anywhere at the Supreme Court.”

Mariotti said he can’t imagine that the court would accept the case.

“It’s important to note that [federal] judges are not elected by anyone,” he said. “And the idea that a judge who’s not elected is going to set aside an election, in which millions of people participated, [is] an extraordinary act that would require an extraordinary justification.”

Posted by dawnawaker

일반인이 얘기하는 다이어트


---------------------------
* 저는 의학을 공부한 적이 없는 일반인이며
  의학적이 이야기 보다는
  실제로 겪은 이야기와 실제로 주변에서 본 이야기들입니다
  다이어트 생각하시는 분들, 특히 일찍 알수록 좋은 이야기들  
---------------------------

1. 주변에서 본 이야기

 

-- 단기간 다이어트 한 어느 중 1 여자아이의 이야기 


키는 그리 크지 않았는데 몸이 좀 뚱뚱했던(반에서 1-2 번째) 이 아이는 어느 날 이모가 

"너 살빼면 이모가 ### 부츠 하나 사줄께" 

라는 말을 듣게 됩니다.

 

평소 좋아하던 그 브랜드 부츠를 신고 싶었고 또 다이어트해야겠다는 마음도 있었기에
그 때 부터 약 6 개월 동안 완전히 살을 빼서 
정말이지 제가 보았을때는 조금 과장하자면
'길가다 살짝 부딪히면 팔다리가 부러질거 같은' 느낌이 들 정도로 
그냥 평범한 체형이 아닌 약간 야윈 체형이었죠.

그동안 쭈~~욱 살이 쪘을때는 신체에 문제가 없던 그 아이는
이렇게 살을 빼고서 몸에 이상이 오기 시작했고,
병원에 가서 검사를 받은 결과 각종 '성인병' 진단을 받아다고 합니다.

 

중요한 것은 살을 빼기 전이 아니라 살을 빼고 나서 그런 진단을 받았다는 거죠.

예전에 본 어느 여배우도 극중의 역 때문에 살을 찌웠다가 맡은 배역을 
끝내고 다시 단기간에 살을 뺐는데, 
그리고서 심장이 안 좋아졌다는 얘기를 인터뷰에서 들은 적이 있고,

또 한때 붐이었던 몸짱 열품으로 다이어트를 해서 단기간(3 - 6 개월)에
살을 뺐던 많은 이들이(특히 연예인들) 건강에 문제가 생겼다는 얘기도 많이 들었죠.

 

단, 모두가 그런것은 아닌걸로 보입니다. 

예전 개그콘서트 '헬스보이' 이승윤씨 같은 경우는 
단기간에 체중 감량을 했지만 딱히 이상이 있었다는 이야기 없이 요즘도 활동을 많이 하고있네요. 


하지만, 100 % 는 아니라도, 이런 단기간 다이어트가 
성인만이 아니라 사춘기 또래의 어린 아이들에게도
건강상 상당한 악영향을 끼칠 가능성이 큰것은 사실로 보입니다.

 

◆◆◆◆◆◆◆◆◆◆◆◆◆◆

 

제가 아는 어느 30대 후반 여성분 이야기입니다.

 

젊은시절 상당한 글래머스타일(살 찐 스타일이 아니라 실제로 남자들이 좋아할 가슴은 크고 허리는 잘록, 다리도 늘씬)이었던 이 분은 어느 때 부터인가 여러가지 상황으로 살이 찌기 시작했고,

심지어 오랜만에 만난 사람에게서 

"못 본사이 임신하셨네요, 축하드려요."

라는 말을 들을 정도가 되었죠.

 

이에 충격을 받고는, 어느 날 부터 다이어트를 해서 단 몇 달만(5-6 개월 정도)에 예전 몸매까지는 아니어도 상당히 체중을 줄이는데 성공했지만, 건강진단 결과 당뇨가 왔다고 하더군요.

 


신체가 적응하지 못하는 단기간의 다이어트는 몸에 상당한 무리를 주는 것으로 보입니다.
적어도 1 년 정도 계획으로 천천히 살을 빼야 몸이 적응을 할 수 있는거 같네요.
(물론 다이어트 중의 영양상태 등도 당연히 신경써야 겠죠)


◆◆◆◆◆◆◆◆◆◆◆◆◆◆

 

이제 저의 이야기 입니다.


우선 전 남자입니다. ^^

약 20 대 중반까지만 해도 허리 사이즈 28 인치 정도였던 것으로 기억하네요.
딱히 운동을 좋아하지도 않았지만 대학생, 군대 등 한창 몸 움직이고 할 때였죠

20대 후반까진 거의 저 상태였었죠.
그동안은 집에서 직장다녔는데 당시 같이 사시던 부모님들은 저녁식사 이후
밤에 뭐 드시는 것을 좋아하지 않으셨고
저도 당연히 저녁 이후에는 가끔 과일 정도 외엔 거의 아무것도 먹지 않았어요.
전형적인 가정식 식사로 지금 생각해 보면 튀김, 치킨, 피자, 햄, 라면 종류는 
거의 안... 아니 못 먹었죠.

 

◆◆◆◆◆◆◆◆◆◆◆◆◆◆


[20대 후반] 

그러다 20대 후반부터 혼자 살게 되었는데,

그러다 보니, 제대로 된 식사를 거의 하지 않고 또 옆에서 말릴 사람이 없었으니 그 때부터

라면, 빵, 과자, 설탕과 크림이 잔뜩 들어간 인스턴트 커피 를 많이 먹기 시작하고

주말이면 대개 치킨, 피자 등을 꼭 먹었었죠.

물론 주중에도 한 번씩은 꼭 먹었던거 같네요.


30대 초반 어느 날, 오랜만에 양복 바지를 꺼내 입었는데
지퍼가 안 올라가더군요.
그래서 바지를 새로 했는데 허리가 무려 34인치.....

30, 32 인치 까지는 별 생각 없었는데, 34 인치 바지를 보고는
충격을 받아서 운동을 시작했어요
그렇다고 헬스장 가지는 않고, 그냥 집안에서 누워서 다리들기 정도....

시간으로 따지면 하루 15 분 정도....

그런데 허리가 2 주만에 다시 약 31 인치 정도로 줄어들었죠.

그래서 전 중대한 착각에 빠집니다.

'아, 나는 체질상 살이 쪄도 2주 운동하면 다시 돌아오는구나.'

 

세월이 지나고서 생각해보면, 
그 당시 2가지 요인으로 체중이 빨리 줄었던거죠.


1. 어릴수록 (30 초 중반까지) 
2. 살이 찐지 얼마 안되는 경우 

 

◆◆◆◆◆◆◆◆◆◆◆◆◆◆


[30대 중후반]

그러다 32 정도를 유지했었고,
30대 중후반 정도에 다시 또 배가 많이 나와서
가벼운 생각으로 또 2주 작정 운동을 시작했는데....

예상과 상당히 다르더군요.

헬스를 다니면서 했는데, 그렇게 운동을 해도 체중이 쉽게 빠지지 않는 겁니다.

사실 헬스를 다니면 단점도 많더군요

1. 시간이 많이 소요된다
   운동하는 시간을 최소 1 시간 + 본격헬스 전후로 몸 풀어주는 시간 
 + 헬스장 갔다오는 시간 + 샤워하고 말리는 시간
   을 다 합치면 실제로는 거의 2 시간 가까이 걸리니까요.
   
2. 지친다
   그래도 헬스장 가면 땀 흘리며 운동하게 되는데,
   유산소운동만 하라는 코치는 없죠.
   일단 근육운동(살빼는데도 근육운동이 중요하다고 하죠)이랑 유산소 운동을
   같이 하다보면 집에오면 일단 퍼져버립니다.
   위 시간들을 다 합치면 그냥 1 시간 정도로 해결될 일은 아니더군요....

여튼 이때부터 살이 붙어서 안 떨어지기 시작하는 겁니다.

 

◆◆◆◆◆◆◆◆◆◆◆◆◆◆


[40 대]
그 이후 거의 허리 32 - 33 정도를 유지했는데, 약 2016 - 2017 년 정도엔
조깅을 해야 겠다는 생각을 했고, 여름 약 3 달 정도
일주일에 3-4 일 정도 밤에 나가서 약 40분 정도 조깅을 했어요.
덥고 습해도 낮에 햇볕에 하는것 보다는 나은 거 같아서 밤에 했는데
그렇게 한 3 달 정도를 하고 나니...

만나는 사람들이 얼굴살이 많이 빠졌다고 하더군요. 
그런데, 정작 중요한 뱃살은 별로 안 빠진 겁니다.

계속 32인치 바지를 입어야 했죠.

◆◆◆◆◆◆◆◆◆◆◆◆◆◆ 

지금까지 상황을 보고 나름대로 정리해본 사항입니다.
(제 생각과 다른 분들도 많을거라 생각하지만
  다이어트 및 살 빼려는 분들에게 도움이 되길)

첫째>  체중관리는 어릴때 부터 하는 것이 좋다.

    여기에는 식단조절과 운동이 중요하다고 합니다.
포하지방이 많이 든 음식 (라면, 빵, 과자, 인스턴트 봉지 커피 등) 을 멀리하고
(콜레스테롤 높아지면, 평생 약을 먹어야 합니다)
튀긴음식 멀리하자 (프라이드치킨 등)

 배가 부를때까지 음식을 먹지 않는 습관을 가지는 것도 넘 중요하죠.

● 어릴때 부터 튀긴음식, 라면, 과자, 기름진 빵, 탄산음료, 달고 짠음식 먹지 않도록 유도
    (특히 짠음식은 많이 먹게 만든다 - 백종원씨는 달고 짜게 를 외칩니다.  그 사람은 요리전문가 라기보다는 사업가이기때문이죠.  자극적인 음식에 입맛 길들여지면 자꾸 찾게 된다는 걸 잘 이용한 대표적인 사람이죠 : 그 사람이 자기 아이들에게도 그렇게 먹으라고 할까 의문입니다)

건강을 위해서라도 어느 정도의 운동을 하도록

둘째>  전에 입던 옷이 작아졌다고 느껴지면 바로 체중관리를 하자.

    살이 찐 초기에는, 조금만 노력해도 다시 살을 뺄 수 있지만,
일단 우리 몸이 쪄버린 몸에 적응하게 되면
엄청난 시간과 노력을 들여도 살을 빼는 것은 매우 어렵다는 것입니다.

그래서 아무리 헉헉거리며 운동을 해도 기껏해야
'얼굴 살 빠졌네 (= 늙어보이네)'
라는 말만 듣게되고,
실제로 허리 사이즈는 줄지 않는다는 것입니다.

셋째>  다이어는 길~~~~~게 보고 하자.
    한달, 석달, 여섯달 다이어트는 위에서 얘기한 것처럼 대단히 위험해 보입니다.
적어도 1년 계획을 잡고 우리 몸이 적응할 수 있는 시간을
주는 것이 중요한것 같아요.

 

넷째> 나이대별 신체적 특징을 이해하자.

    성장기와 20대초반에 먹던 양을 그대로 30대, 40대에도 먹으면 당연히 빠지지 않겠죠.

 

◆◆◆◆◆◆◆◆◆◆◆◆◆◆

 

TV 에 나오는 어느 유명한 의사는 이런 말을 합니다.

 

"다이어트를 하려면 평생을 할 수 있는 방법을 찾으세요.  다이어트를 끝내면 요요가 오니까요."

 

 

 

Posted by dawnawaker
[prog] SQL - MSSQL2020. 11. 4. 13:14

 

Contents at a Glance                                                          
Chapter 1 Select: Single Table  
Chapter 2 Where 
Chapter 3 Order By  
Chapter 4 Select: Multiple Tables 
Chapter 5 Aggregates  
Chapter 6 Select: New Tables  
Chapter 7 Except/Intersect/Union  
Chapter 8 Group By  
Chapter 9 System Functions  
Chapter 10 Subqueries 
Chapter 11 Delete/Insert/Update 
Chapter 12 Views/User-Defined Functions 
Chapter 13 Stored Procedures/Programming  
Chapter 14 Data Definition Language (DDL) and Data Control Language (DCL) 
Chapter 15 After You Finish 
Index

1. 사용할 데이터베이스 다운로드

   - 마이크로소프트에서 제공하는 테스트용 DB 를 다운로드 받는다.
   - 구글에서 adventureworksDW2008 database download 검색

 

 

 

 

2. 다운로드 받은 백업 DB 를 SSMS 에서 설치

------------------------------------------------------

Chapter 1 Select: Single Table 

 

 

 

Chapter 11  Delete / Insert / Update 

 

○ Select Into 
   기존에 없는 새 테이블을 만들어서 데이터 입력 
   기존에 있는 테이블에 데이터를 넣으려면 Insert Select 
select * 
into Scenario 
from DimScenario 


-- Scenario 테이블을 만들어서 
   DimScenario 테이블에 있는 모든 data 를 Scenario 테이블에 복사해 넣는다
-- 새로 만들어지는 Scenario 테이블은 PK, FK 등의 key 속성은 복사하지 않지만
   IDENTITY 속성은 복사한다.

 

DimScenario, Scenario 모두 동일

 

delete Scenario 
-------------------
select * 
into Scenario 
from DimScenario 


-- [결과] error  (데이터는 삭제되었지만 Scenario 라는 테이블이 존재하므로)

 

○ Truncate Table  : 테이블은 남기고 데이터만 삭제 
    Drop Table       : 테이블째로 삭제 
truncate table Scenario

 

 

○ Insert Into ... Select 1/3 
   - 기존에 있는 테이블에 데이터 입력 
   - Identity 칼럼이 있는 경우 주의 
insert into Scenario
select * from DimScenario


-- 결과
메시지 8101, 수준 16, 상태 1, 줄 15
테이블 'Scenario'에 있는 ID 열의 명시적 값은 열 목록이 사용되고 IDENTITY_INSERT가 ON일 때만 지정할 수 있습니다.


-- 설명
현재 Scenario 는 빈 테이블인데, 이 중 ScenarioKey 칼럼이 IDENTITY 속성.
IDENTITY 속성인 칼럼에 복사를 하려하면 위처럼 error 발생.

○ Insert Into ... Select  2/3 
   - 일부 칼럼만 복사
insert into Scenario
select ScenarioName from DimScenario


-- 결과
3 rows affected


-- 설명
존재하고 있는 Scenario 테이블에 DimScenario 테이블로 부터 ScenarioName 칼럼을 복사해 넣는다

 

○ Insert Into ... Select 3/3 
   - 일부 칼럼만 복사 
   - source 칼럼과 destination 칼럼 모두 명시
insert into Scenario (ScenarioName) 
select ScenarioName from DimScenario


-- 설명
존재하고 있는 Scenario 테이블의 ScenarioName 칼럼에
DimScenario 테이블로 부터 ScenarioName 칼럼을 복사해 넣는다

 

결과 화면

 

○ delete 테이블명 / truncate table 테이블명  차이
  - delete    : identity 칼럼 번호를 계속 이어간다
  - truncate : identity 칼럼 번호를 1 로 리셋
-- DELETE / truncate 차이

drop table Scenario

select * 
into Scenario 
from DimScenario 


select * from DimScenario

select * from Scenario

delete Scenario
-- truncate table Scenario  -- 이 부분만 바꾸어서 실행

insert into Scenario
select ScenarioName from DimScenario

select * from Scenario
delete 결과 truncate 결과

마지막 테이블 ScenarioKey 칼럼 4 부터 시작

마지막 테이블 ScenarioKey 칼럼 1 부터 시작

 

 

○ Delete 를 하고 identity 번호를 다시 1 부터 넣는 방법
  - dbcc checkident()
drop table Scenario

select * 
into Scenario 
from DimScenario ;

select * from DimScenario;  --  첫번째 결과

select * from Scenario;     --  두번째 결과

delete Scenario;

dbcc checkident(Scenario, reseed, 0);

insert into Scenario
select ScenarioName from DimScenario;

select * from Scenario;     -- 세번째 결과

 

identity 칼럼은 일반적인 insert 문이나 update 문으로는 insert 도, update 도 할 수 없다.

 

 

○ Identity 칼럼에 특정 숫자를 insert 하자
  - set identity_insert Scenario on   (off 로 하면 다시 원래대로 못쓰게 함)
  - 이때, 원하는 칼럼리스트를 넣어주어야 한다.
set identity_insert Scenario on
--
insert into Scenario                   -- 실패 (칼럼명이 없다)
values(90,'Forecast 2011')
--
insert into Scenario (ScenarioKey, ScenarioName)  -- 성공 (칼럼명이 있다)
values(99,'Forecast 2011')
--
set identity_insert Scenario off       -- 다시 원래대로
--
select * from Scenario

두 번째 쿼리의 결과

 

○ Identity 칼럼은 중간에 번호가 비어도 마지막 번호부터 이어간다.
select * from [dbo].[Scenario]        -- 결과 1
-------------------
insert into Scenario (ScenarioName)
values ('Forecast 2012')

insert into Scenario (ScenarioName)
values ('Forecast 2013')
-------------------
select * from Scenario                 -- 결과 2

 

◆◆◆◆◆◆◆◆◆◆◆◆◆

◆◆◆◆◆◆◆◆◆◆◆◆◆

 

Chapter 12  Vuews / User-Defined Functions

** 여기서는 table function 은 다루지 않고 scalar function 만 다룬다.

1. Join Select 문을 View 로

-- 테이블 3개를 join 한 select 문

select EnglishProductName, EnglishProductSubcategoryName, EnglishProductCategoryName 
from DimProduct                  as P
inner join DimProductSubcategory as S
   on P.ProductSubcategoryKey = S.ProductSubcategoryKey
inner join DimProductCategory    as C
   on S.ProductCategoryKey = C.ProductCategoryKey
where EnglishProductCategoryName = 'Bikes' or
      EnglishProductCategoryName = 'Accessories'

 

1. View 만들기
  - Create View 뷰이름 as + select 문
-- 위 SQL 문을 VIEW 로 만든다.

create view MyView as            -- 이 부분만 새로 들어간다
select EnglishProductName, EnglishProductSubcategoryName, EnglishProductCategoryName 
from DimProduct                  as P
inner join DimProductSubcategory as S
   on P.ProductSubcategoryKey = S.ProductSubcategoryKey
inner join DimProductCategory    as C
   on S.ProductCategoryKey = C.ProductCategoryKey
where EnglishProductCategoryName = 'Bikes' or
      EnglishProductCategoryName = 'Accessories'

 

 

2. 위에서 만들어진 VIEW 를 테이블처럼 사용한다 - SELECT
select * from MyView

 

3. VIEW 수정
  - Alter view 뷰이름 as + select 문
-- 위 VIEW 를 수정한다.

alter view MyView as             -- Alter VIEW
select EnglishProductName, EnglishProductSubcategoryName, EnglishProductCategoryName 
from   DimProduct                as P
inner join DimProductSubcategory as S
        on P.ProductSubcategoryKey = S.ProductSubcategoryKey
inner join DimProductCategory    as C
        on S.ProductCategoryKey    = C.ProductCategoryKey
where EnglishProductCategoryName = 'Clothing' or
      EnglishProductCategoryName = 'Components'
--
select * from MyView

 

 

4. VIEW 삭제
  - Drop view 뷰이름
drop view MyView

 

 

◆◆◆◆◆◆◆◆◆◆◆◆◆

 

◆ User-Defined Function

1. 함수 만들기
  - create function 함수명(@파라미터  데이터타입)
    returns 데이터타입
    as
    begin
      함수수식
      return
    end

-- 테스트를 위한 base 쿼리를 만든다.

select EnglishProductName as [Product], round(ListPrice,2) as [Price],
       ceiling(ListPrice * 0.15) as [Tax] 
from   DimProduct
where  ListPrice is not null

** 여기서 Tax 구하는 부분을 함수로 만들어본다.

 

use AdventureWorksDW2008R2
go

create function Tax (@price money)
returns int
as
begin
  return ceiling(@price * 0.15)
end

-- 입력 파라미터 의 데이터타입 : money

    리턴 파라미터의 데이터타입 : int  (그대로 money 써도 되지만 연습을 위해)

 

2. 함수 사용
  - select 스키마명.함수(입력파라미터)
select dbo.Tax(20)

-- select Tax(20)  : error

 

select EnglishProductName as [Product], round(ListPrice,2) as [Price],
        dbo.Tax(ListPrice) as Tax 
from   DimProduct         -- 함수 사용
where  ListPrice is not null

 

3. 함수 삭제
  - Drop function 함수명
drop function Tax   -- 위 예제에서 사용한 Tax 함수를 삭제한다

 

 

4. 예제]  정수 3개를 받아서 모두 곱한 값을 리터하는 함수(CalculateVolume) 작성
create function CalculateVolume (@x int, @y int, @z int)
returns int
as
begin
  return @x * @y * @z
end
--
select dbo.CalculateVolume(12,5,3) as Volume       -- 결과 1
--
select dbo.CalculateVolume(12.9,5,3) as Volume     -- 결과 2

-- [모두 확인후 함수 삭제]
drop function CalculateVolume

 

위 결과 1 과 결과 2 는 모두 180 이다.

 - 12.9 * 5 * 3 = 193.5

 - 입력값 데이터 타입이 모두 int 이므로 소수점 이하는 모두 잘라서 입력된다.

 

 

◆◆◆◆◆◆◆◆◆◆◆◆◆

◆◆◆◆◆◆◆◆◆◆◆◆◆

 

Chapter 13  Stored Procedure / Programming

 

1. WHILE 문
  - END WHILE 은 없다
  - Begin ... End 는 가능
-- begin ... end 없는 경우

declare @counter int

set @counter = 1
while @counter < 3
set @counter = @counter + 1
print @counter

-- 결과

   3

-- 설명  : 아래 두 문장이 한 세트 / print @counter 는 while 에 속하지 않는다.
   while @counter < 3
   set @counter = @counter + 1

 

 

-- begin ... end 있는 경우

declare @counter int
set @counter = 1
print @counter

while @counter < 3
begin
  set @counter = @counter + 1
  print @counter
end

-- 결과

   1

   2

   3

 

2. RETURN
  - 프로그램실행을 끝낸다.
print 'starting'
return
print 'finished'

-- 결과

  starting

 

 

3. If ... Else
  - Then / End If 없음
프로그램실행을 끝낸다.
if 1 <> 0
print 'true'
print 'got here'
else
print 'false'

-- 결과

   error

-- 설명

   if 1 <> 0 에는 print 'true' 만 적용된다.  따라서 else 부분이 문제가 된다. 

   위 프로그램을 실행시키려면 Begin ... End 를 사용한다.

 

if 1 <> 0
begin
  print 'true'
  print 'got here'
end
else
  print 'false'
  
-- 결과
-- true
-- got here     
if 1 <> 0
begin
print 'true'
print 'got here'
end
else
print 'false'
print 'got here too'


/* ----------------------
결과
true
got here
got here too
---------------------- */

여기서 if 문은 begin ~ print 'false' 까지.

 

if 1 <> 0
begin
print 'true'
print 'got here'
end
else
begin
print 'false'
print 'got here too'
end

/* ----------------------
결과
true
got here
---------------------- */

 

 

4. Case ... When ... End
  - Then 사용 가능
declare @minute tinyint
set @minute = datepart(mi,getdate())
declare @OddEven bit
set @OddEven = @minute %2
select
case @OddEven
when 0 then 'Even'
when 1 then 'Odd'
else 'Unknown'
end as [Minute]

/* ----------------------
결과
Odd  (or Even)
---------------------- */

 

 

5. Select 문에서 변수 사용
nchar(1) 타입으로 maritalstatus 라는 변수를 선언하고
이 변수에 'M' 을 넣고
DimCustomer 테이블에서 MaritalStatus 가  변수 maritalstatus 의 값을 가지는 데이터 select
declare @maritalstatus nchar(1)
set @maritalstatus = 'M'
select * from DimCustomer
where MaritalStatus = @maritalstatus

 

 

Stored Procedure 로 넘어가기 위한 Base 쿼리

 

select FirstName + ' ' + LastName as [Full Name], MaritalStatus, Gender
from DimCustomer

 

1. Create Proc 프로시저명 as
   Begin
     ...
   End
-- first stored procedure
create proc GetCustomers as
select FirstName + ' ' + LastName as [Full Name], MaritalStatus, Gender
from DimCustomer


-- better
create proc GetCustomers as
begin
select FirstName + ' ' + LastName as [Full Name], MaritalStatus, Gender
from DimCustomer
end

 

 

2. Alter Proc 프로시저명 as
   Begin
     ...
   End
alter proc GetCustomers as
begin
-- [Full Name] 을 Fullname 으로 변경
select FirstName + ' ' + LastName as [Fullname], MaritalStatus, Gender
from DimCustomer
end

 

3. 실행 : exec procedure명
alter proc GetCustomers as
begin
select FirstName + ' ' + LastName as [Full Name], MaritalStatus, Gender
from DimCustomer
where MaritalStatus = 'S' and Gender = 'F'
end

--------------------------

-- 실행
exec GetCustomers

 

 

4. procedure 에 내부 변수 사용
-- where 절에 변수 사용
alter proc GetCustomers as
begin

declare @maritalstatus nchar(1)  -- 내부 변수
declare @gender nvarchar(1)      -- 내부 변수
set @maritalstatus = 'S'
set @gender = 'F'

select FirstName + ' ' + LastName as [Full Name], 
       MaritalStatus, 
       Gender
from   DimCustomer
where  MaritalStatus = @maritalstatus 
       and Gender = @gender
end


-- 실행
exec GetCustomers

/* --------------------------------
결과 :
MaritalStatus = S 이고 Gender = F 인 row 출력
-------------------------------- */

 

 

5. procedure 에 input parameter 사용
alter proc GetCustomers
@maritalstatus nchar(1),  -- 외부 변수
@gender nvarchar(1)       -- 외부 변수
as
begin

select FirstName + ' ' + LastName as [Full Name], 
       MaritalStatus, 
       Gender
from   DimCustomer
where  MaritalStatus = @maritalstatus 
       and Gender = @gender
	   
end


-- 실행 1
exec GetCustomers         -- error

-- 실행 2
exec GetCustomers 'S', 'F'

/* ------------------------
실행 2 의 결과 :
MaritalStatus = S  Gender = F 인 row select
/* ------------------------

 

 

6. procedure 에 input parameter 사용  +  변수에 default 값 주기
alter proc GetCustomers
@maritalstatus nchar(1) = 'S',
@gender nvarchar(1) = 'F'
as
begin

select FirstName + ' ' + LastName as [Full Name], 
       MaritalStatus, 
       Gender
from   DimCustomer
where  MaritalStatus = @maritalstatus 
       and Gender = @gender

end


-- 실행 1
exec GetCustomers


-- 실행 2
exec GetCustomers 'M', 'M'

/* ---------------------------
실행 1 결과 :
default 로 설정된 F / S 값이 들어간 row select

실행 2 결과 :
입력된 파라미터 M /M 값이 들어간 row select
--------------------------- */

 

 

7.  Output Parameter 사용 
alter proc GetCustomers
@maritalstatus nchar(1) = 'S',
@gender nvarchar(1) = 'F',
@count int out                  -- out parameter 선언
as
begin

select FirstName + ' ' + LastName as [Full Name], 
       MaritalStatus, 
       Gender
from   DimCustomer
where  MaritalStatus = @maritalstatus 
       and Gender = @gender

set @count = @@ROWCOUNT

end


/*******************************

-- 실행 1
exec GetCustomers

-- 실행 2
exec GetCustomers 'M', 'F'

-- 실행 3
exec GetCustomers @count out

-- 실행 4
declare @count int
exec GetCustomers 'M', 'M', @count out
select @count as [Records]

-- 실행 5  p. 265
declare @count int
exec GetCustomers , , @count out
select @count as [Records]

-- 실행 6  p. 265
declare @count int
exec GetCustomers default, default, @count out
select @count as [Records]

-- 실행 7  p. 265
declare @count int
declare @return int
exec @return = GetCustomers default, default, @count out
select @count as [Records]
select @return as [Return]

*******************************/

 

실행 결과

-- 결과 1
프로시저 또는 함수 'GetCustomers'에 매개 변수 '@count'이(가) 필요하지만 제공되지 않았습니다.

-- 결과 2
프로시저 또는 함수 'GetCustomers'에 매개 변수 '@count'이(가) 필요하지만 제공되지 않았습니다.

-- 결과 3
스칼라 변수 "@count"을(를) 선언해야 합니다.

-- 결과 4
   Records
----------
1  5266

-- 결과 5
',' 근처의 구문이 잘못되었습니다.

-- 결과 6
   Records 
---------- 
1  4388 


-- 결과 7
   Records 
------------ 
1  4388 

   Return 
------------ 
1  0 

 

 

8.  Output Parameter + Return  in Procedure
-- p. 267
alter proc GetCustomers
@maritalstatus nchar(1) = 'S',
@gender nvarchar(1) = 'F',
@count int out
as
begin

declare @err int

select FirstName + ' ' + LastName as [Full Name], 
       MaritalStatus, 
       Gender
from   DimCustomer
where  MaritalStatus = @maritalstatus 
       and Gender = @gender

set    @count = @@ROWCOUNT

if @count = 0
  return -99
else
  return 0

end


/****************************************
declare @count int
declare @return int
exec @return = GetCustomers 'X', 'Y', @count out
-- X, Y 를 넣으면 row 는 0개 select
select @count as [Records]
select @return as [Return]
****************************************/

 

 

결과 :

   Records 
------------ 
1  0 

   Return 
------------ 
1  -99

 

 

9. Procedure 에서 다른 Procdure 호출
-- p. 268
create proc CallGetCustomers as
begin

declare @count int
declare @return int

exec @return = GetCustomers 'S', 'F', @count out

select @count as [Records]
select @return as [Return]

end


/***********************************
실행 :
exec CallGetCustomers
***********************************/

 

결과 :

   Records 
------------ 
1  4388

   Return 
------------ 
1  0

 

 

10. Try ... Catch  

 

-- p. 269
alter proc CallGetCustomers as
begin

declare @count int
declare @return int

begin try
  exec @return = GetCustomers 'S', 'F', @count out
  // GetCustomers 'S', 'F', @count out 호출하면 리턴값 = 0
end try

begin catch
  set @count = 0
  set @return = -100

  print ERROR_MESSAGE()
end catch

select @count as [Records]
select @return as [Return]

end


/******************************
exec CallGetCustomers
******************************/

 

결과 :

   Records 
------------ 
1  4388

   Return 
------------ 
1  0

설명 : Try block 에서 문제가 발생하면 Catch block 이 trigger 된다

 

만일 GetCustomers 에서 from   DimCustomer 을  from   XXXX 라고 하고 실행하면

결과 :

   Return 
------------ 
1  -100

 

 

11. Procedure 호출부분에 input parameter 넣어주기

 

-- p. 271

alter proc CallGetCustomers
@maritalstatus nchar(1)    = 'S',
@gender        nvarchar(1) = 'F'
as
begin

declare @count int
declare @return int

begin try
  -- input parameter 에 상수가 아닌 변수를 넣어준다
  exec @return = GetCustomers @maritalstatus, @gender, @count out
end try

begin catch
  set @count = 0
  set @return = -100

  print ERROR_MESSAGE()
end catch

select @count as [Records]
select @return as [Return]

end


/*****************************************
-- 실행 1
exec CallGetCustomers 'X', 'Y'  -- 결과 row 개수 = 0

-- 실행 2
exec CallGetCustomers default, default

-- 실행 3
exec CallGetCustomers 'S', 'M'
*****************************************/

 

결과 1 :
   Records 
------------ 
1  0

   Return 
------------ 
1  -99
--------------------------------

결과 2 :
   Records 
------------ 
1  4388

   Return 
------------ 
1  0
--------------------------------

결과 3 :
   Records 
------------ 
1  4085

   Return 
------------ 
1  0


 

Posted by dawnawaker
[prog] SQL - MSSQL2020. 10. 15. 15:30

SQL SERVER / MS SQL / SSMS / SQL SERVER MANAGEMENT STUDIO / tips (v. 18.5)

 

  • 에디터
  1. 라인 번호 넣기 :
    도구  >  옵션  >  텍스트 편집기  >  Transact-SQL  >  일반  >  ☑  줄 번호 
  2. 블럭 선택 : Alt 누른채 마우스 드래그

 

 

Posted by dawnawaker
[prog] SQL - MSSQL2020. 10. 11. 02:26

From blog.naver.com/diceworld/220156570441

 

- 기준날짜

​   2000년 01월 02일 13시 14분 15.678초 기준 날짜 형변환

 

 - MSSQL 날짜 변환표 (기준날짜를 대상으로 CONVERT 실행하여 날짜 형변환)

번호

쿼리

 결과 코드

 0

 CONVERT(CHAR(19), DATETIME, 0)

 01 02 2000 1:14PM  MM DD YYYY H:MM

 1

 CONVERT(CHAR(10), DATETIME, 1)

 01/02/2000

 MM/DD/YYYY

 2

 CONVERT(CHAR(8), DATETIME, 2)

 00.01.02

 YY.MM.DD

 3

 CONVERT(CHAR(8), DATETIME, 3)

 02/01/00

 DD/MM/YY

 4

 CONVERT(CHAR(8), DATETIME, 4)

 02.01.00

 DD.MM.YY

 5

 CONVERT(CHAR(8), DATETIME, 5)

 02-01-00

 DD-MM-YY

 6

 CONVERT(CHAR(8), DATETIME, 6)

 02 01 00

 DD MM YY

 7

 CONVERT(CHAR(9), DATETIME, 7)

 01 02, 00

 MM DD, YY

 8

 CONVERT(CHAR(8), DATETIME, 8)

 13:14:15

 HH:MM:SS

 9

 CONVERT(CHAR(26), DATETIME, 9)

 01 02 2000 1:14:15.678PM

 NN DD YYYY H:MM:SS.MS

 10

 CONVERT(CHAR(8), DATETIME, 10)

 01-02-00

 MM-DD-YY

 11

 CONVERT(CHAR(8), DATETIME, 11)

 02/01/00

 DD/MM/YY

 12

 CONVERT(CHAR(6), DATETIME, 12)

 000102

 YYMMDD

 13

 CONVERT(CHAR(24), DATETIME, 13)

 02 01 2000 13:14:15.678

 DD MM YYYY HH:MM:SS.MS

 14

 CONVERT(CHAR(12), DATETIME, 14)

 13:14:15.678

 HH:MM:SS.MS

 20

 CONVERT(CHAR(19), DATETIME, 20)

 2000-01-02 13:14:15

 YYYY-MM-DD HH:MM:SS

 21

 CONVERT(CHAR(23), DATETIME, 21)

 2000-01-02 13:14:15.678

YYYY-MM-DD HH:MM:SS.MS

 22

 CONVERT(CHAR(20), DATETIME, 22)

 01/02/00 1:14:15 PM

 MM/DD/YY H:M:S

 23

 CONVERT(CHAR(10), DATETIME, 23)

 2000-01-02

 YYYY-MM-DD

 24

 CONVERT(CHAR(8), DATETIME, 24)

 13:14:15

 HH:MM:SS

 25

 CONVERT(CHAR(23), DATETIME, 25)

 2000-01-02 13:14:15.678

 YYYY-MM-DD HH:MM:SS.MS

 100

 CONVERT(CHAR(19), DATETIME, 100)

 01 02 2000 1:02PM

 MM DD YYYY H:MM

 101

 CONVERT(CHAR(10), DATETIME, 101)

 01/02/2000

 MM/DD/YYYY

 102

 CONVERT(CHAR(10), DATETIME, 102)

 2000.01.02

 YYYY.MM.DD

 103

 CONVERT(CHAR(10), DATETIME, 103)

 02/01/2000

 DD/MM/YYYY

 104

 CONVERT(CHAR(10), DATETIME, 104)

 02/01/2000

 DD/MM/YYYY

 105

 CONVERT(CHAR(10), DATETIME, 105)

 02-01-2000

 DD-MM-YYYY

 106

 CONVERT(CHAR(11), DATETIME, 106)

 02 01 2000

 DD MM YYYY

 107

 CONVERT(CHAR(12), DATETIME, 107)

 01 02, 2000

 MM DD, YYYY

 108

 CONVERT(CHAR(8), DATETIME, 108)

 13:14:15

 HH:MM:SS

 109

 CONVERT(CHAR(26), DATETIME, 109)

 01 02 2000 1:14:15.678PM

 MM DD YYYY H:MM:DD.MS

 110

 CONVERT(CHAR(10), DATETIME, 110)

 01-02-2000

 MM-DD-YYYY

 111

 CONVERT(CHAR(10), DATETIME, 111)

 2000/01/02

 YYYY/MM/DD

 112

 CONVERT(CHAR(8), DATETIME, 112)

 20000102

 YYYYMMDD

 113

 CONVERT(CHAR(24), DATETIME, 113)

 02 01 2000 13:14:15.678

 DD MM YYYY HH:MM:DD.MS

 114

 CONVERT(CHAR(12), DATETIME, 114)

 13:14:15:678

 HH:MM:DD:MS

 120

 CONVERT(CHAR(19), DATETIME, 120)

 2000-01-02 13:14:15

 YYYY-MM-DD HH:MM:SS

 121

 CONVERT(CHAR(23), DATETIME, 121)

 2000-01-02 13:14:15.678

 YYYY-MM-DD HH:MM:SS.MS

 126

 CONVERT(CHAR(23), DATETIME, 126)

 2000-01-02T13:14:15.678

 YYYY-MM-DDT HH:MM:SS.MS

 127

 CONVERT(CHAR(23), DATETIME, 127)

 2000-01-02T13:14:15.678

 YYYY-MM-DDT HH:MM:SS.MS

 131

 CONVERT(CHAR(25), DATETIME, 131)

 1/06/1421 1:13:14:678PM

 

 

 [참고사항] 자주 쓰이는 변환표

 

번호

쿼리

 결과 코드

 21

 CONVERT(CHAR(23), DATETIME, 21)

 2000-01-02 13:14:15.678 YYYY-MM-DD HH:MM:SS.MS

 23

 CONVERT(CHAR(10), DATETIME, 23)

 2000-01-02

 YYYY-MM-DD

 112

 CONVERT(CHAR(8), DATETIME, 112)

 20000102

 YYYYMMDD

 

 - 예제 1

오늘 날짜를 YYYY-MM-DD 형태로 CONVERT를 이용하여 표시하시오. (2000년 01월 02일 13시 14분 15초 기준)

 

 - 예제 1 쿼리

SELECT CONVERT(CHAR(10), GETDATE(), 23) AS 날짜

 

날짜

2000-01-02

 

 - 예제 2

오늘 날짜를 YYYY-MM-DD HH:MM:SS.MS 형태로 CONVERT를 이용하여 표시하시오.   

(2000년 01월 02일 13시 14분 15초 기준)

 

 - 예제 2 쿼리

 SELECT CONVERT(CHAR(23), GETDATE(), 21) AS 날짜

 

날짜

2000-01-02 13:14:15.678

  

 [참고사항] GETDATE()

 GETDATE()함수는 오늘날짜를 연, 월, 일, 시, 분, 초, 밀리세컨드까지 갖고 오는 함수입니다.

 


 

  • 생일을 기준으로 한 만나이 계산

    도움 :  ponyozzang.tistory.com/413

 

-- 생년월일
DECLARE @BIRTHDAY DATE = '2000-11-05';

-- 나이를 알고 싶은 날짜
DECLARE @DATE DATE = GETDATE();   -- '2020-11-05'

-- 년수 계산
DECLARE @AGE  INT = (SELECT DATEDIFF(YEAR, @BIRTHDAY, @DATE));

-- 생년월일 자르기
DECLARE @D  VARCHAR(8) = CONVERT(VARCHAR(8), @DATE,     112);
DECLARE @B  VARCHAR(8) = CONVERT(VARCHAR(8), @BIRTHDAY, 112);
DECLARE @D2 VARCHAR(8) = LEFT(@D, 4) + RIGHT(@B, 4);

-- 만나이 계산
SET @AGE = CASE
	WHEN @D < @D2 THEN
		@AGE - 1
	ELSE
		@AGE
	END

-- 만나이 출력
SELECT @AGE

 

 

 

 

 

Posted by dawnawaker
카테고리 없음2020. 9. 24. 16:56

1. EDITPLUS

 

1. editplus

   메뉴 - 도구 - 디렉토리 지정 에서 ini 파일 및 문서 템플릿 폴더 경로 확인 가능

 

 

  ini 파일 디렉토리 로 들어갔을때, 

  editplus_u.ini  : editplus 환경설정

  setting.ini      : color 설정등

  ftp2_u.ini       : FTP 계정설정

 

Posted by dawnawaker