Combination of two objects by their attribut in only one table

Hornlui

Benutzer
Beiträge
8
hello,
i´ve got two tables a and b that i want to "put together". if their fk: ram (a.ram, b.ram) has the same amount of bids from table b=bids(count* from bids as numberbids) the couples should be shown like this:
example:
---------------------------------
ram1 ram2 numberbids
1 2 2
1 5 2
5 2 2
i really hope someone can help
Thanks!
 
Werbung:
please show us table-definition and table-data. And please keep in mind: this is a german speaking forum, so can we switch to german?

Regards, Andreas
 
Hello Andreas,
dankeschön.
a
--------
ram
a
b



b
------
d
ram
bid

ich brauche:
ram1 ram2 NumberBids
-------------------------------------
immer kombinationen von den 2 rams(=fk), die zusammen gleiche ANzahl bids haben
 
ich sehe keinen Weg, um aus den gezeigten Tabellen das zu erhalten, was im ersten Post dargestellt wurde. Aber vermutlich nur deswegen, weil ich exakt gar nicht verstehe, was das alles soll.

PS.: bitte nutze [ code ] - Tags für Code-Abschnitte. Es gibt hier im Forum auch eine Online-Hilfe, die das erklärt.
 
Ich habe die Daten nicht, nur diese Übersicht
Code:
tabellea
ram
a
b


Code:
tabelleb
ram
b
bid

nun möchte ich die kombinationen von artikeln, die beide, die gleiche anzahl bids haben.
Also habe ich
Select tabellea.ram as ram1, tabelleb.ram as ram2,  count(*) as Numberofbids from tabellea inner join tabelleb
on tabellea.ram=tabelleb.ram
group by tabellea.ram,tabelleb.ram;
abgefragt. dadurch erhalte ich das:
[CODE]
[ram1][ram2][Numberofbids]
2 5 2
4 4 5
2 1 2
1 5 2
3 3 6

also weiss ich, dass 1,2 und 5 die gleich Anzahl gebote haben und möchte jetzt eine tabelle ausgebe, in der nur diese kombinationen vorkommen. Und hierbei weiß ich nicht wie das zu machen ist.
Danke
 
Mit Deinen Daten erhalte ich:

Code:
test=*# select * from table_a;
 ram
-----
 a
 b
(2 Zeilen)

test=*# select * from table_b;
 ram
-----
 b
 bid
(2 Zeilen)

test=*# select table_a.ram as ram1, table_b.ram as ram2, count(*) as numberofbids from table_a inner join table_b on table_a.ram=table_b.ram group by 1,2;
 ram1 | ram2 | numberofbids
------+------+--------------
 b  | b  |  1
(1 Zeile)

test=*#

Mir ist unverständlich, wie Deine gewünschte Ergebnissmenge zustande kommen soll.
 
mir ist unverständlich was du da gemacht hast. wie kannst du abfragen von tabellen machen, auf die du keinen zugriff hast? ich habe die datenübersich(Tabellen) aufgeschrieben und was ich gemacht habe.
verstehst du denn was die aufgabe ist?
 
Werbung:
Zurück
Oben