使用select时格式化sql列

时间:2015-05-28 02:58:03

标签: sql sql-server

我有以下查询来选择记录,但我想在结果集上格式化列。

SELECT 
    COALESCE(dbo.tblMitchellLandscapeID.PatchSize,0) as PatchSize,
    dbo.tblMitchellLandscape.MitchellLandscapeName
FROM tblMitchellLandscapeID
INNER JOIN dbo.tblMitchellLandscape
      ON dbo.tblMitchellLandscapeID.MitchellLandscapeID=dbo.tblMitchellLandscape.MitchellLandscapeID
WHERE AssessmentVersionID = @AssessmentVersionID

" PatchSize"是十进制值,因此它总是存储为两位小数" 15.10"。所有我试图在执行select语句时格式化为一个小数我想填充结果集,如" 15.1"而不是15.10。

1 个答案:

答案 0 :(得分:7)

您可以将其转换为您想要的格式:

beforeEach(module("FleetTask", function ($provide) {
     productGroupFactory = jasmine.createSpyObj('productGroupFactory', ['save']);
      $provide.value('ProductGroupFactory', productGroupFactory);
}));



beforeEach(inject(function (_settings_, $rootScope, $controller) {
     scope = $rootScope.$new();
     settings = _settings_;
     //...
 }));


 it('Access Factory', function () {
     expect(settings).toBeDefined();
  });

请注意,如果使用表别名,查询也更容易阅读(和写入)。