简体   繁体   中英

How to fix “ABAP INNER JOIN”

i'm trying to get a inner join from two select sentences but it doesn't work, what i am doing wrong?

i cant work with internal tables because inner join doesn't permit it.

clear: it_spfli.
  refresh: it_spfli.

  select 
    spfli-cityto
    spfli-cityfrom
    into TABLE it_spfli from(select spfli-cityto COUNT( * )from spfli group by spfli-cityto) as t1
    INNER JOIN(select spfli-cityfrom COUNT( * )from spfli group by spfli-cityfrom) as t2
    ON t1-cityto = t2-cityfrom.

i expect a table of more frequency city to and city from order by city to with table spfli .

There is simply no data. You select flights whose start and end city are identical. There are probably no such flights in spfli.

First of all i don't think you are doing the right SELECT to get what you want. I answer this question from the technical perspective. You can use WITH .

WITH +spf1 AS (
  SELECT spfli~cityto AS cityto, COUNT(*) AS count FROM spfli GROUP BY spfli~cityto ) ,

     +spf2 AS (
  SELECT spfli~cityfrom AS cityfrom , COUNT(*) AS count FROM spfli GROUP BY spfli~cityfrom ) ,

     +spf3 AS ( 
  SELECT s1~cityto, s2~cityfrom FROM +spf1 AS s1 INNER JOIN +spf2 AS s2
      ON s1~cityto = s2~cityfrom )

SELECT * FROM +spf3 INTO TABLE @DATA(lt_result).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM