<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>nabi_director.log</title>
        <link>https://velog.io/</link>
        <description>개발공부하는 마케터</description>
        <lastBuildDate>Mon, 10 Apr 2023 15:14:42 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>nabi_director.log</title>
            <url>https://velog.velcdn.com/images/nabi_director/profile/e6c7bcb2-14a0-4727-9648-bcfdf8d8c340/social_profile.jpeg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. nabi_director.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/nabi_director" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[sql 문법 정리하기]]></title>
            <link>https://velog.io/@nabi_director/sql-%EB%AC%B8%EB%B2%95-%EC%A0%95%EB%A6%AC%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@nabi_director/sql-%EB%AC%B8%EB%B2%95-%EC%A0%95%EB%A6%AC%ED%95%98%EA%B8%B0</guid>
            <pubDate>Mon, 10 Apr 2023 15:14:42 GMT</pubDate>
            <description><![CDATA[<ol>
<li><p>select * from</p>
</li>
<li><p>where
 != : 같지 않음
 between A and B : A와 B사이
 in(A,B,C...) : A,B,C를 포함하는
 like ~ % : ~의 규칙이 있는?</p>
</li>
<li><p>이 외에 유용한 문법
 limit
 distinct
 count</p>
</li>
<li><p>통계
 min/max
 avt</p>
</li>
<li><p>반복되는 일을 줄여주는 group by</p>
</li>
<li><p>뽑아낸 데이터 정렬 order by</p>
</li>
<li><p>별칭 as 이름값</p>
</li>
<li><p>붙여주기
 left join Atable on a.field = b.field : (B엔 없는 값이 있어도)A기준으로 붙인다. 
 inner join Btalbe on b.field = c.field : 교집합 개념</p>
</li>
<li><p>union</p>
</li>
<li><p>subquery () 괄호 안에 쿼리 넣기</p>
</li>
</ol>
]]></description>
        </item>
        <item>
            <title><![CDATA[3주차 강의 join 연습]]></title>
            <link>https://velog.io/@nabi_director/3%EC%A3%BC%EC%B0%A8-%EA%B0%95%EC%9D%98-join-%EC%97%B0%EC%8A%B5</link>
            <guid>https://velog.io/@nabi_director/3%EC%A3%BC%EC%B0%A8-%EA%B0%95%EC%9D%98-join-%EC%97%B0%EC%8A%B5</guid>
            <pubDate>Thu, 06 Apr 2023 15:39:04 GMT</pubDate>
            <description><![CDATA[<p>join을 할 때 어떤 테이블을 어떤 필드로 묶어줄 것인가에 대해
고민이 많이 필요하다는 것을 배웠다.</p>
<p>같은 필드 값이더라도
각 테이블에서 필드가 의미하거나 기준이 되는 것들이 다르기 때문에</p>
<p>보고자 하는 데이터에 맞춰
join으로 붙여주고
group by로 묶어줄 때도 어떤 테이블의 어떤 필드로 묶을 것인지 고민해야 한다는 것.</p>
<p>점점 알아갈 수록 쉽지 않지만
배우는 바도 있고 재미있는 것 같다.</p>
<p>실전에서 더 활용 해보고 싶다.</p>
<p>아래는 오늘 연습한 코드들</p>
<pre><code>select co.title, ch.week, count(*) as cnt from courses co
inner join checkins ch on co.course_id = ch.course_id
inner join orders o on ch.course_id = o.course_id 
where o.created_at &gt;= &quot;2020-08-01&quot;
group by co.title, ch.week 
order by co.title, ch.week 



SELECT * from point_users pu 

select u.name, count(*) as cnt from users u 
left join point_users pu on u.user_id = pu.user_id 
where pu.point_user_id is not NULL 
group by u.name



select count(pu.point_user_id) as pnt_user_cnt, count(*) as tot_user_cnt, round(count(pu.point_user_id)/count(*),2) as ratio 
from users u 
left join point_users pu on u.user_id = pu.user_id 
where u.created_at BETWEEN &quot;2020-07-10&quot; and &quot;2020-07-20&quot;



(
    select &#39;7월&#39; as month, c1.title, c2.week, count(*) as cnt from courses c1
    inner join checkins c2 on c1.course_id = c2.course_id
    inner join orders o on c2.user_id = o.user_id
    where o.created_at &lt; &#39;2020-08-01&#39;
    group by c1.title, c2.week
)
union all
(
    select &#39;8월&#39; as month, c1.title, c2.week, count(*) as cnt from courses c1
    inner join checkins c2 on c1.course_id = c2.course_id
    inner join orders o on c2.user_id = o.user_id
    where o.created_at &gt;= &#39;2020-08-01&#39;
    group by c1.title, c2.week
)

select ed.enrolled_id, e1.user_id, count(ed.done = 1) as cnt from enrolleds e1
inner join enrolleds_detail ed on e1.enrolled_id = ed.enrolled_id 
group by ed.enrolled_id 
order by cnt


select ed.enrolled_id, e1.user_id, count(*) as cnt from enrolleds e1
inner join enrolleds_detail ed on e1.enrolled_id = ed.enrolled_id 
where ed.done = 1
group by ed.enrolled_id, e1.user_id
order by cnt desc</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[SQL] 2일차 order by, group by]]></title>
            <link>https://velog.io/@nabi_director/SQL-2%EC%9D%BC%EC%B0%A8-order-by-group-by</link>
            <guid>https://velog.io/@nabi_director/SQL-2%EC%9D%BC%EC%B0%A8-order-by-group-by</guid>
            <pubDate>Sun, 19 Mar 2023 16:09:42 GMT</pubDate>
            <description><![CDATA[<h1 id="오늘의-학습-목표">오늘의 학습 목표</h1>
<h2 id="1-통계치를-구하는-문법">1. 통계치를 구하는 문법</h2>
<h3 id="1-최소-min--최대-max">1) 최소 min / 최대 max</h3>
<h3 id="2-평균-avg---round-반올림-문법과-함께-많이-사용">2) 평균 avg - round 반올림 문법과 함께 많이 사용</h3>
<h3 id="3-개수">3) 개수</h3>
<h2 id="2-group-by">2. Group by</h2>
<h3 id="ㄴ-반복되는-일을-줄여주는-쿼리-배우기">ㄴ 반복되는 일을 줄여주는 쿼리 배우기</h3>
<h2 id="3-order-by">3. Order by</h2>
<h3 id="ㄴ-뽑아낸-데이터-정렬하기">ㄴ 뽑아낸 데이터 정렬하기</h3>
<h4 id="ㄴ-기본적으로는-오름차순">ㄴ 기본적으로는 오름차순</h4>
<h4 id="ㄴ-내림차순으로-하려면-desc-문법-추가로-써줘야함">ㄴ 내림차순으로 하려면 desc 문법 추가로 써줘야함</h4>
<h4 id="tip">tip.</h4>
<ul>
<li><strong>쿼리가 실행되는 순서</strong>
from &gt; group by &gt; select(&lt;- 이게 타 언어에서 print와 비슷한 역할을 하는건가?) &gt; order by</li>
</ul>
<ul>
<li><strong>쿼리를 이렇게 작성하면 편리하다.</strong></li>
</ul>
<ol>
<li>show tables 로 전체 테이블 살피고</li>
<li>제일 원하는 정보, 필드가 있을 것 같은 테이블을 <strong>&lt;selec*from 테이블명&gt;</strong> 으로 불러온다 (데이터가 많을 때는 **limit(( 를 사용)</li>
<li>원하는 정보가 나오는 테이블을 발견 할 때까지 2반복</li>
<li>원하는 테이블이 나오면 쿼리문을 날릴 필드를 찾기</li>
<li>범주별로 통계를 보고싶은 필드를 찾기</li>
<li>SQL쿼리 작성</li>
</ol>
<h3 id="별칭-alias">별칭 alias</h3>
<p>1) 테이블과 필드에 별명을 줄 수 있다.
2) select 로 보여줄 결과값의 필드명을 <strong>&lt;as 특정이름값&gt;</strong> 문법을 사용해 &#39;특정이름값&#39; 을 필드값으로 변환해 보여줄 수 있다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[SQL] 1일차 select, where 배우기]]></title>
            <link>https://velog.io/@nabi_director/SQL-1%EC%9D%BC%EC%B0%A8-select-where-%EB%B0%B0%EC%9A%B0%EA%B8%B0</link>
            <guid>https://velog.io/@nabi_director/SQL-1%EC%9D%BC%EC%B0%A8-select-where-%EB%B0%B0%EC%9A%B0%EA%B8%B0</guid>
            <pubDate>Sun, 19 Mar 2023 09:11:18 GMT</pubDate>
            <description><![CDATA[<ul>
<li>Select 쿼리문은
  ㄴ 어떤 테이블에서
  ㄴ 어떤 필드의 데이터를 가져올지로 구성된다.</li>
</ul>
<ul>
<li>테이블은 엑셀에서 시트 하나와 비슷한 의미</li>
<li>필드는 각 열의 제목이 되는, 데이터가 쌓이는 대표 이름을 필드라고 함</li>
</ul>
<p>테이블 &gt; 필드 &gt; 문자열, 숫자 등의 값
이렇게 포함되는 개념이라고 보면 될듯.</p>
<blockquote>
<p>select 필드(혹은 전체를 의미하는 * 별) from 테이블</p>
</blockquote>
<p>보통 이런식으로 시작한다.</p>
<p>그 외에도 where과 함께 쓰이는 문법 등을 배웠다.</p>
<ul>
<li><p>같지 않음 !=</p>
</li>
<li><p>범위 between A and B</p>
</li>
<li><p>포함 in(A,B,C...)</p>
</li>
<li><p>패턴 like &#39;%<del>~</del>&#39; 
  ㄴ 패턴 문법이 재밌고 더 유용한 이유는 특정 문자열 규칙에 대해 조건을 걸어 줄 수 있어서다.</p>
</li>
<li><p>일부데이터만 가져오기 limit(숫자)</p>
</li>
<li><p>중복데이터 거르기 distinct()</p>
</li>
<li><p>개수세기 count() - 괄호안에 값의 행 개수를 세어준다.</p>
</li>
</ul>
<hr>
<p>생각보다 어렵지 않고
내가 원하는 값을 바로바로 추출 해낼 수 있다는게
굉장히 흥미로운 수업이었다.
바로 실무에 적용 해보고 싶다.
엑셀이나 스프레드 시트의 값들을 DB화 시켜서 SQL 쿼리로
값을 추출 해낼 수 있는지 공부해보고 싶다.</p>
]]></description>
        </item>
    </channel>
</rss>