我可能失去了一些東西,但我沒有看到從你的歌表專輯直接關係..
我首先將link_interpret_song表加入到歌曲表中,並獲得不同專輯的數量。但是,我沒有看到歌曲表的字段列表中看起來是「No_Album」列。我只能猜測它在那裏與特定專輯相關聯。我確實看到了媒體,但對我來說,這將像是一種媒體類型(數字,下載,乙烯基,CD),而對於專輯表來說,實際的ID鍵卻很明顯。
這就是說,我認爲在SONG表中有這樣的「No_Album」列。
select
LIS.No_Interpret,
COUNT(DISTINCT S.No_Album)
from
Link_Interpret_Song LIS
JOIN Song S
on LIS.No_Song = S.No_Song
group by
LIS.No_Interpret;
現在,這就是說,如果你想要解釋細節,可以把上面的結果加入到解釋表中。我已經做了兩個截然不同的專輯數量和歌曲總#就像數()與計數(不同的)情況下的一個例子...如
select
PreCounts.No_Interpret,
PreCounts.DistinctAlbums,
PreCounts.ActualSongs,
I.Name_Interpret,
I.First_Name,
I.Stage_Name
from
(select
LIS.No_Interpret,
COUNT(DISTINCT S.No_Album) as DistinctAlbums,
COUNT(*) as ActualSongs
from
Link_Interpret_Song LIS
JOIN Song S
on LIS.No_Song = S.No_Song
group by
LIS.No_Interpret) as PreCounts
JOIN Interpret I
ON PreCounts.No_Interpret = I.No_Interpret
選擇interpret.no_interpret,從相冊COUNT(*) 小組由interpret.no_interpret; – Fergus 2013-04-11 02:58:30
「相冊」和「解釋」表**相關的**如何?你能否確定'Primary'和'Foreign'鍵? – 2013-04-11 03:01:24
它通過NO_Interpret,通過No_Song解釋關聯到link_InterpretSong到LInk_Interpret_song;但我看不出No_Album與歌曲或詮釋的關係。沒有這些知識我不認爲任何人都可以幫助 – xQbert 2013-04-11 03:01:38