with temp_01 as ( select d.category_name, to_char ( date_trunc ('month', a.order_date), 'yyyymm') as month_day, sum (amount) as sum_amount, count ( distinct a.order_id) as monthly_ord_cnt from orders a join order_items b on a.order_id = b.order_id join products c on b.product_id = c.product_id join categories d on c.category_id = d.category_id group by d.category_name, to_char ( date_trunc ('month', a.order_date), 'yyyymm') ) select *, sum (sum_amount) over ( partition by month_day order by month_day) as temp1, sum (sum_amount) over ( partition by month_day) as temp2, sum_amount / sum (sum_amount) over ( partition by month_day) as ratio from temp_01 집계 어날리틱 함수는 order by를 사용하면 파티션 내에서 누적합이 되는것으로 알고 있었는데 왜 이렇게 나올까요...? 제가 혹시 놓친게 있는 걸까요
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. select, from, limit 다 완벽하게 작성한 것 같은데 오류가 나서 질문글 찾아보니 limit 뒤에 세미콜론을 안적어서 그렇다는데 저는 적어도 저렇게 나오는데 이유가 뭘까요?
@RunWith(SpringRunner.class) @SpringBootTest public class MemberRepositoryTest { @Autowired MemberRepository memberRepository; @Test @Transactional @Rollback(false) public void testMember() throws Exception { //given Member member = new Member(); member.setUsername("memberA"); //when Long saveId = memberRepository.save(member); Member findMember = memberRepository.find(saveId); //then assertThat(findMember.getId()).isEqualTo(member.getId()); assertThat(findMember.getUsername()).isEqualTo(member.getUsername()); assertThat(member).isEqualTo(findMember); System.out.println("findMember == member: " + (findMember == member)); } } 위 코드에서 디비에 넣은 멤버와 찾은 멤버가 같은지를 비교를 isEqualTo를 사용을 하셨는데 이것은 제가 알기론 value부분만 같다면 true라는것으로 알고 있습니다. 같은 영속성 컨텍스트 안에서의 객체가 같은지 확인하려면 isSameAs가 맞지 않은지 의문이 생겼습니다!
2가지의 풀이 방법을 알 수 있었습니다 -- 1번 풀이 : 서브쿼리 select salary * months as earnings , count(*) from employee where salary * months = (select max(salary*months) from employee) group by earnings -- 2번 풀이 : order by , limit select salary * months as earnings , count(*) from employee group by earnings order by earnings desc limit 1 궁금한 사항은 두가지 방법 중 어느 코드의 성능이 더 좋게 평가 되는지 궁금합니다.
해당 문제를 풀 때 다음과 같이 코드를 작성했는데요. SELECT City FROM Station WHERE City LIKE 'a%' or 'e%' or 'i%' or 'o%' or 'u%'; 결과물을 보니까 A로 시작하는 CITY만 출력되더라고요. OR로 연결되는 모든 조건에는 컬럼명과 LIKE를 써줘야 하닌데, 'a%' 뒤에 있는 것들은 그렇지 않아서 결과로 출력되지 않은 건가요? AND도 OR처럼 여러 번 쓰면 뒤에 컬럼명과 LIKE를 또 써줘야 하나요?
일단 새로운 프로젝트 만들고 premain 추가해주는 것 까진 강의를 그대로 따라하시면 됩니다. manifest plugin 부터 조금 차이가 있어서 거기부터 설명하면, build gradle 에 다음과 같이 추가한다. tasks.named('jar') { manifest { attributes( 'Implementation-Title': project.name, 'Implementation-Version': project.version, 'Premain-Class' : "com.java.magicianAgent.MagicianAgent", 'Can-Redefine-Classes' : true, 'Can-Retransform-Classes' : true) } } 터미널에서 다음 명령어를 통해 build 한다 ./gradlew clean build build.libs file 안에 있는 jar file 을 확인한다. (옵션) 강의에서와 마찬가지로 zip file 로 변경하면 확인가능합니다. 저같은 경우 SNAPSHOT.jar 과 SNAPSHOT -plain.jar 이렇게 2개가 생겼는데 SNAPSHOT.jar 은 제가 spring boot 로 실행서 그런지 관련 설정들이 보이고 SNAPSHOT -plain.jar 이 맞는거 같더라구요. jar file 의 절대 경로를 복사해 VM option 에 추가한다. 여기서부터는 다시 강의와 같습니다. VM option 이 안보이시면 오른쪽에 Modify options 클릭하면 add vm options 라고 보이실 겁니다. 이상한거나 궁금한거 있으시면 말씀해주세요. gradle 을 쓰시는 모든 분들도 마술을 성공시킵시다 하하
2일째 고민을 해보았는데.. 2%까지만 맞고 틀리다고 합니당..ㅠㅠ 포기하고 싶지 않은 마음에 도움을 요청합니다!! 제가 짠 코드는 이렇습니다! import java.io.*; import java.util.*; // 불이 하나가 아닌 여러개일 수 있다. public class Main { public static int R; public static int C; public static String[][] map; public static int[][] visitedFire; public static int[][] visitedHuman; public static int[] dx; public static int[] dy; public static Node fireLocation; public static Node humanLocation; public static Queue<Node> fireQueue; public static void main(String[] args) throws IOException { // 초기화 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokenizer st = new StringTokenizer(br.readLine()); R = Integer.parseInt(st.nextToken()); C = Integer.parseInt(st.nextToken()); map = new String[R][C]; // 0으로 초기화 visitedFire = new int[R][C]; visitedHuman = new int[R][C]; dx = new int[]{0,1,0,-1}; dy = new int[]{-1,0,1,0}; fireQueue = new LinkedList<>(); // 맵 입력 for (int i = 0; i < R; i++) { String S = br.readLine(); for (int j = 0; j < C; j++) { // 불 좌표, 지훈이 좌표 찾기 map[i][j] = String.valueOf(S.charAt(j)); if(map[i][j].equals("J")){ humanLocation = new Node(j,i); map[i][j] = "."; // .으로 변경 }else if(map[i][j].equals("F")){ // 불이 여러개, 불이 아무것도 없을 수 있다. -> 반레 fireLocation = new Node(j,i); fireQueue.add(fireLocation); visitedFire[i][j] = 1; } } } // (1) 불이 이동할 수 있는 최단경로 fireBfs(); // (2) 사람이 이동할 수 있는 최단경로 + 길 비교해야함 humanBfs(humanLocation.y, humanLocation.x); // 가능한 길 찾아서 int result = Integer.MAX_VALUE; // (3) 가장 짧은 최단거리 찾기 (가장자리 찾기) for (int i = 0; i < visitedHuman.length; i++) { for (int j = 0; j < visitedHuman[i].length; j++) { if((0<i && i<R-1) && 0 < j && j < C-1)continue; // 가장자리가 아닌 경우 pass if(visitedHuman[i][j] > 0) { result = Math.min(result, visitedHuman[i][j]); } } } if(result == Integer.MAX_VALUE){ System.out.println("IMPOSSIBLE"); }else{ System.out.println(result); } } public static void humanBfs(int y, int x){ // tkfk visitedHuman[y][x] = 1; Node node = new Node(x,y); Queue<Node> queue = new LinkedList<>(); queue.add(node); while(queue.size()>0){ Node cur = queue.poll(); for (int i = 0; i < 4; i++) { int nx = cur.x + dx[i]; int ny = cur.y + dy[i]; if(nx < 0 || nx >= C || ny < 0 || ny >= R) continue; if(visitedHuman[ny][nx] == 0 && (map[ny][nx].equals("."))){ if(visitedHuman[ny][nx] < visitedFire[ny][nx] || visitedFire[ny][nx] == 0){ visitedHuman[ny][nx] = visitedHuman[cur.y][cur.x] + 1; Node next = new Node(nx,ny); queue.add(next); } } } } } public static void fireBfs(){ while(fireQueue.size()>0){ Node cur = fireQueue.poll(); for (int i = 0; i < 4; i++) { // 4방향 탐지 int nx = cur.x + dx[i]; int ny = cur.y + dy[i]; if(nx < 0 || nx >= C || ny < 0 || ny >= R) continue; if(visitedFire[ny][nx] == 0 && (map[ny][nx].equals("."))){ visitedFire[ny][nx] = visitedFire[cur.y][cur.x] + 1; // 이동함을 표현 Node next = new Node(nx,ny); fireQueue.add(next); } } } } public static class Node { int x; int y; Node(int x, int y){ this.x = x; this.y = y; } } }
강의 따라해도 생성이 안되서 골머리를 앓았는데 -- This script does not create a database. -- Run this script in the database you want the objects to be created. -- Default schema is dbo. 이렇게 적혀있더라고요. 이제 테이블을 자동으로 생성해주지 않아요 테이블 만들고 코드 복붙하면 데이터가 생깁니다. 그럼 이만
기본 학습테이블인 BONUS, DEPT, EMP, SALGRADE 가 요즘 쓰는 SQL Developer 버전에는 없네요.. 그래서 테이블 코드 복사해서 입력하면 자꾸 지정한 월이 부적합합니다. 오류가 뜨는데 해결을 못하고있어서 강의를 못듣고 있습니다 ..ㅠㅠ 해결방법좀 알려주세요.
안녕하세요. 윈도우 11 사용하고 있습니다. 실습 자료를 복원하는데 아래와 같은 문구가 나오면서 안 됩니다 .. 해결방법이 있을까요 ? unrecognized win32 error code: 123pg_restore: error: could not open input file "C:\Users\DS\Documents\???\????_?????_????\data_schema.backup": Invalid argument