-1

私は3つのテーブルを持っています

private static final String DTReasonTable = "create table tb_DTReasons(DTReasonId integer primary key autoincrement,DTReason text)";

private static final String ConfigurationTable = "create table tb_Config(ConfigId integer primary key autoincrement," +
        "RawMaterialName text,OutPut_pdt text,TotalWorkHrs real,Quantity real,ProcessStartTime real,OutputQuantity real,procesEndTime real)";

private static final String DownTimeTable = "create table tb_DownTimeTable(DT_Id integer primary key autoincrement,ConfigId integer," +
        "StartTime real,EndTime real,DTReasonId integer)";

以下のようなレポートを作成したい

ここに画像の説明を入力

対応するレポート生成の手順を書くのを手伝ってくれる人はいますか?

  public Cursor getDtAnalysisReport()
{
    return this.data.rawQuery("select EndTime-StartTime as duration,tb_DTReasons.DTReason,count(tb_DownTimeTable.DTReasonId) from tb_DownTimeTable" +
            " inner join tb_DTReasons on tb_DownTimeTable.DTReasonId = tb_DTReasons.DTReasonId group by tb_DownTimeTable.DTReasonId ", null);

}

これは私が試したものですが、エラーが発生しています。解決策を見つけるのを手伝ってください。

4

1 に答える 1

0
SELECT DTReason AS 'Down Time Reason',
       SUM(EndTime - StartTime) AS 'Duration',
       SUM(EndTime - StartTime) /
       (SELECT SUM(EndTime - StartTime)
        FROM tb_DownTimeTable
       ) * 100 AS '% Total Down Time',
       COUNT(*) AS 'No of Occurrences'
FROM tb_DTReasons
JOIN tb_DownTimeTable ON tb_DTReasons.DTReasonId = tb_DownTimeTable.DTReasonId
GROUP BY tb_DTReasons.DTReasonId
于 2013-05-20T12:21:58.290 に答える