這裏下面是MT數據庫表如何查詢,從而獲得所需的數據
CREATE TABLE [dbo].[mtblLog_Book](
[Logbook_Number] [int] IDENTITY(1,1) NOT NULL,
[Sno] [int] NULL,
[Vehicle_Number] [nvarchar](100) NULL,
[Vehicle_Booking_Date] [datetime] NULL,
[Time_From] [datetime] NULL,
[Time_To] [datetime] NULL,
[KM_Start] [int] NULL,
[KM_End] [int] NULL,
[Total] [int] NULL,
[Vehicle_Used_By] [varchar](100) NULL,
[Cost_Code] [nvarchar](50) NULL,
[Budget_Line] [nvarchar](50) NULL,
[Entry_Date] [datetime] NULL
) ON [PRIMARY]
有反覆Cost_Code
。我需要一個查詢,這樣我可以在下面的格式獲得數據
CostCode1
......................
All data which belong to CostCode1
......................
CostCode2
......................
All data which belong to CostCode2
......................
CostCode3
......................
All data which belong to CostCode3
......................
續....到CostCode * ň *
感謝
你不能在兩者之間打印出頭條新聞的方式。在Sql中,每個查詢結果必須具有相同數量的顏色。那麼'SELECT * FROM dbo.mtblLog_Book ORDER BY Cost_Code' – JaMaBing 2013-03-22 09:37:33