如何在SQL中找到最常用的工具

时间:2019-01-12 18:02:15

标签: sql database

当前,我的表包括两个-设施表Facility table和预订表Booking table

如何列出会员在2017年使用最多的最受欢迎设施?

  1. 年份必须是2017年

  2. 每月使用次数最多的设施

尝试后

This is what I have now

SELECT 
    MONTH(b.BookingStartDateTime) AS 'Month', 
    f.FacilityDesc AS 'MOST FREQUENT'
FROM
    Booking b
INNER JOIN 
    Facility f ON b.FacilityID = f.FacilityID
WHERE
    YEAR(b.BookingStartDateTime) = 2017
GROUP BY
    MONTH(b.BookingStartDateTime), f.FacilityDesc
ORDER BY 
    MONTH(b.BookingStartDateTime) DESC

1 个答案:

答案 0 :(得分:1)

我相信这应该可行。

com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_NAME_NOT_FOUND (0xc0000034): Create failed for <file path>

添加了非窗口函数版本,您需要进行内部联接或在其中存在方法以获取结果

String fileName ="EricTestFile.txt";
String fileContents = "Mary had a little lamb.";

SMBClient client = new SMBClient();
try (Connection connection = client.connect(serverName)) {
    AuthenticationContext ac = new AuthenticationContext(username, password.toCharArray(), domain);
    Session session = connection.authenticate(ac);

    // Connect to Share
    try (DiskShare share = (DiskShare) session.connectShare(sharename)) {
        for (FileIdBothDirectoryInformation f : share.list(folderName, "*.*")) {
            System.out.println("File : " + f.getFileName());
        }

        //share.openFile(path, accessMask, attributes, shareAccesses, createDisposition, createOptions)
        Set<FileAttributes> fileAttributes = new HashSet<>();
        fileAttributes.add(FileAttributes.FILE_ATTRIBUTE_NORMAL);
        Set<SMB2CreateOptions> createOptions = new HashSet<>();
        createOptions.add(SMB2CreateOptions.FILE_RANDOM_ACCESS);
        File f = share.openFile(folderName+"\\"+fileName, new HashSet(Arrays.asList(new AccessMask[]{AccessMask.GENERIC_ALL})), fileAttributes, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OVERWRITE, createOptions);

        OutputStream oStream = f.getOutputStream();
        oStream.write(fileContents.getBytes());
        oStream.flush();
        oStream.close();
    }
} catch (IOException e) {
    e.printStackTrace();
}