2011-09-26 72 views
-4

我想從比賽(分數和回合)建立一個桌面聯盟。SQL Server桌面聯盟

我從我的SQL Server數據庫succceeded計算點,每個球隊和比賽,但我現在想生成表格聯賽..(足球)

有些人能幫助我嗎?

SELECT  TOP (100) PERCENT dbo.jos_joomleague_matches.match_id, dbo.jos_joomleague_clubs.name AS Team, jos_joomleague_clubs_1.name AS Team2, 
         dbo.jos_joomleague_matches.match_date, dbo.jos_joomleague_matches.matchpart1_result, dbo.jos_joomleague_matches.matchpart2_result, 
         dbo.jos_joomleague_rounds.name, 
         CASE WHEN dbo.jos_joomleague_matches.matchpart1_result > dbo.jos_joomleague_matches.matchpart2_result THEN 3 WHEN dbo.jos_joomleague_matches.matchpart1_result 
         = dbo.jos_joomleague_matches.matchpart2_result THEN 1 ELSE 0 END AS ptsclub1HOME, 
         CASE WHEN dbo.jos_joomleague_matches.matchpart2_result > dbo.jos_joomleague_matches.matchpart1_result THEN 3 WHEN dbo.jos_joomleague_matches.matchpart2_result 
         = dbo.jos_joomleague_matches.matchpart1_result THEN 1 ELSE 0 END AS ptsclub2AWAY 
FROM   dbo.jos_joomleague_rounds INNER JOIN 
         dbo.jos_joomleague_clubs AS jos_joomleague_clubs_1 INNER JOIN 
         dbo.jos_joomleague_matches INNER JOIN 
         dbo.jos_joomleague_clubs ON dbo.jos_joomleague_matches.matchpart1 = dbo.jos_joomleague_clubs.id ON 
         jos_joomleague_clubs_1.id = dbo.jos_joomleague_matches.matchpart2 ON dbo.jos_joomleague_rounds.id = dbo.jos_joomleague_matches.round_id 
ORDER BY dbo.jos_joomleague_matches.match_date 

`

+1

向我們展示(1)您當前的表結構和幾行示例數據(2)您期望的結果。 –

+2

這是什麼問題?你描述你想要的東西,但不是你所做的任何事情,沒有表格結構,沒有起點。 – JNK

回答

3

開始與你的問題的自然語言描述你創建表之前。想想關係:

A 有很多teams。 A match有兩個teams,它們在給定的date上播放並具有特定的outcome

我看到三個表格:,teammatch。從那些開始。

如果您已經在考慮查詢,那麼您還爲時過早。首先獲得基本的表結構。