MySQL Forums
Forum List  »  German

Re: Komplizierte Abfrage...
Posted by: Harald Bacik
Date: August 10, 2012 10:40AM

Hallo
Leicht umgebaut, kommt das der Sache schon näher:

SELECT u.article, u.powera, u.powerb, anzahl
FROM (SELECT a.article,
p.powera_re AS PowerA, p.powerB_re AS PowerB,
COUNT(*) AS anzahl
FROM article a
JOIN POWER p
ON a.powerid = p.id
WHERE a.type = 1
GROUP BY PowerA, PowerB

UNION

SELECT a.article,
p.powera_li AS PowerA, p.powerB_li AS PowerB,
COUNT(*) AS anzahl
FROM article a
JOIN POWER p
ON a.powerid = p.id
WHERE a.type = 2
GROUP BY PowerA, PowerB

) u;

Ergibt:

article powera powerb anzahl
Article B -3.00 \N 1
Article A -2.00 \N 1
Article A -2.00 -0.75 1
Article A -1.00 \N 1

Was vom Grundschema schon passt, nur die Anzahl mit immer 1 stimmt leider nicht...

Options: ReplyQuote


Subject
Views
Written By
Posted
1762
July 24, 2012 04:57AM
1087
August 06, 2012 10:50AM
1083
August 09, 2012 03:00AM
1086
August 09, 2012 03:51AM
1001
August 10, 2012 08:22AM
1048
August 10, 2012 10:19AM
1095
August 10, 2012 10:30AM
Re: Komplizierte Abfrage...
1086
August 10, 2012 10:40AM
1034
August 10, 2012 11:13AM
954
August 10, 2012 11:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.