Hello,

I am developing an application with SQLite. There is this report and my SQL
knowledge is not good enough to cope with it. I do not want to do all these
calculations by regular select statements and writing an application code.
Details;

I have below two tables in the same SQLite database file:
CREATE TABLE IF NOT EXISTS FIS(
  ID                  Integer  NOT NULL PRIMARY KEY AUTOINCREMENT,
  UniqueID            Char(48) not null COLLATE NOCASE,
  EKU                 integer  not null check (EKU > 0),
  ZNo                 integer  not null check(ZNo > 0),
  FNo                 integer  not null check(FNo > 0),
  Tarih               date     not null,
  Saat                time     not null,
  Zaman               datetime not null,
  Barkod              Char(10) COLLATE NOCASE NOT NULL,
  KdvOran             Float    not null check(KdvOran >= 0),
  Miktar              Float    not null,
  Birim               Char(10) COLLATE NOCASE,
  OrjinalBirimFiyat   Float    not null check(OrjinalBirimFiyat >= 0),  
  KartBirimFiyat      Float    not null check(KartBirimFiyat >= 0),
  TeraziBirimFiyat    Float    not null check(TeraziBirimFiyat >= 0),
  IndirimliBirimFiyat Float    not null check(IndirimliBirimFiyat >= 0),
  PromosyonFiyat      Float    not null check(PromosyonFiyat >= 0),
  BirimFiyat          Float    not null check(BirimFiyat >= 0),
  KDVTutar            Float    not null,
  Tutar               Float    not null,
  Kasiyer             Char(20) not null COLLATE NOCASE,
  OturumID            SmallInt not null,
  Vardiya             SmallInt check(Vardiya > 0),
  VeresiyeKodu        Char(20) COLLATE NOCASE,
  POSSeriNo           Char(50) not null COLLATE NOCASE,
  POSFisYazmaSuresi   integer  not null check(POSFisYazmaSuresi >= 0)
);

CREATE TABLE IF NOT EXISTS FISODEME(
  ID                Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  EKU               integer not null check (EKU > 0),
  ZNo               integer not null check(ZNo > 0),
  FNo               integer not null check(FNo > 0),
  Tarih             date not null,
  Saat              time not null,
  Zaman             datetime not null,
  OdemeTuru         Smallint not null check(OdemeTuru in (1, 2, 3)),
  KDVTutari         Float not null check(KDVTutari >= 0),
  FisToplami        float not null check(FisToplami >= 0),
  OdemeMiktari      float not null check(OdemeMiktari >= 0),
  ParaUstu          float not null check(ParaUstu >= 0),
  Banka             Char(20) COLLATE NOCASE,
  VeresiyeKodu      Char(20) COLLATE NOCASE,
  POSSeriNo         Char(50) not null COLLATE NOCASE
);

It is not easy for me to explain the report by written words. So, I prepared
an excel file with 3 sheets. First two contains raw data from above tables.
Last one is the report itself. Please ignore yellow marked columns in raw
data sheets.

I am quite open to add new table(s) for reporting purposes if that makes the
report possible/easier.

It doesn't need to be a single SQL. Running several SQL statements is not a
problem at all. However, I do not want to deal with 10s of SQL statements if
it can be done for example with only 3. It will be something as 10s of
statements If I am to deal with it using my own knowledge.

I appreciate any help.

Regards,
Ertan Küçükoğlu

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to