多个leftjoin重复计数
各位大神,今天见到一个sql,如下,查询t1.id有在与t2.id进行左联结时的条数,发现运用了大量重复的左联结,感觉很不好,但又不知道怎么修改这个sql,请指教: create table t1(id number);create table t2(id number,val varchar2(10));select a1.id,count(
各位大神,今天见到一个sql,如下,查询t1.id有在与t2.id进行左联结时的条数,发现运用了大量重复的左联结,感觉很不好,但又不知道怎么修改这个sql,请指教:
create table t1(id number); create table t2(id number,val varchar2(10)); select a1.id,count(1) from t1 a1 left outer join t2 b1 on a1.id = b1.id and b1.val = 'a' left outer join t2 b2 on a1.id=b2.id and b2.val='b' left outer join t2 b2 on a1.id=b2.id and b2.val='c' left outer join t2 b2 on a1.id=b2.id and b2.val='d' left outer join t2 b2 on a1.id=b2.id and b2.val='e' group by a1.id;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many friends who use the edge browser on win10 have encountered the problem of web pages opening repeatedly, which is a headache. So how to solve it? Let’s take a look at the detailed solutions below. What to do if the edge browser keeps opening web pages repeatedly: 1. Enter the edge browser and click the three dots in the upper right corner. 2. Click "Settings" in the taskbar. 3. Find "Microsoft edge opening method". 4. Click the drop-down menu and select "Start Page". 5. Restart the browser after completion to solve the problem.

How to extract only one piece of duplicate data in Oracle database? In daily database operations, we often encounter situations where we need to extract duplicate data. Sometimes we want to find one of the duplicate data instead of listing all the duplicate data. In Oracle database, we can achieve this purpose with the help of some SQL statements. Next, we will introduce how to extract only one piece of duplicate data from the Oracle database and provide specific code examples. 1. Use ROWID function ROWID is Ora

The fluent query builder in Laravel is an interface responsible for creating and running database queries. The query builder works well with all databases supported by Laravel and can be used to perform almost any database operation. The advantage of using the fluent query builder is that it protects against SQL injection attacks. It utilizes PDO parameter binding and you are free to send strings as needed. The fluent query builder supports many methods such as count, min, max, avg, sum to get summary values from the table. Now let us see how to get the count in select query using fluent query builder. To use the fluent query builder, use the database facade class as shown below useIllumi

How to play multiple sounds at the same time in win7 system? Today I will share with you how to operate a computer to play multiple sounds at the same time. For example, while listening to music, we want to share short videos sent by friends faster, so how can we make their sounds play at the same time? Let’s take a look at the guide for playing multiple sounds at the same time in win7 system brought by the editor below! Guide to playing multiple sounds at the same time in win7 system 1. Right-click the volume icon in the lower right corner of the desktop and select the playback device, as shown in the figure below: 2. In the opened interface, right-click the speaker and select Properties, as shown in the figure below: 3 . In the opened speaker properties window, switch to the advanced settings interface, then uncheck Allow applications to exclusively control the device, and click

Speaking of windows system, I believe many people are familiar with it. Many of us are now using windows system, and windows contains multiple system versions, including win7 and win8.1. Some netizens don’t know whether to choose win7 or 8.1 system. Which one is better, win7 or 8.1? The master will tell you the differences and choices between win7 and win8.1. Windows8.1 has a gorgeous interface. But the improvements are greater, and the shortcomings are also greater. The more obvious ones include blurred game fonts and insufficient memory bugs. No matter how large the memory is, when running some games, it will prompt that the memory is insufficient and needs to be closed. In fact, during the inspection, the memory was normal. One is that there is a problem with the memory management mechanism, and the other is that

Why does the same bubbling event happen twice? Event bubbling is a common event delivery mechanism in browsers. When an element triggers an event, the event will be passed from the triggered element to the upper elements in sequence until it is passed to the root element of the document. This process is like bubbles bubbling in water, so it is called event bubbling. However, sometimes we find that the same bubbling event occurs twice. Why is this? There are two main reasons: event registration and event processing. First, we need to make it clear that the event

Why is the event bubbling triggered twice? In front-end development, we often encounter the concept of event bubbling. Event bubbling means that when a specific event of an element is triggered on the page, the event will be passed layer by layer to the upper element until it is finally passed to the document object. However, sometimes we may encounter the problem of event bubbling and triggering twice, even if we only bind the event listener once. So why does the phenomenon of repeated triggering occur? Let’s dive into the possible reasons below. First, we need to clarify the concept of event risk

In this section, we will see how to create a child process in C language using fork(). We also perform a few different tasks in each process. So in our parent process, we're going to print different values. When fork() is called, it returns a value. If this value is greater than 0, then it is currently in the parent process, otherwise it is in the child process. So we can differentiate processes through this. Sample code#include<stdio.h>#include<unistd.h>intmain(){ intn=fork();//subdivideprocess&
