You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.
How can I perform the following queries (Inner Join on 2 times the same table) in Anko?
#Select for liters per 100 km and dateSELECTFuelData1.Id, FuelData2.TimestampDate, (FuelData2.Fueled/ (FuelData2.Mileage-FuelData1.Mileage) *100) AS LitersPer100Km
FROM FuelData AS FuelData1
INNER JOIN FuelData AS FuelData2
OnFuelData1.Id= (FuelData2.Id-1);
#Select for costs on monthly basisSELECTSUM(FuelData.Fueled*FuelData.Price) AS PricePerMonth, FuelData.MonthYearFROM FuelData
GROUP BYFuelData.MonthYear;
#Select for costs on yearly basisSELECTSUM(FuelData.Fueled*FuelData.Price) AS PricePerYear, FuelData.YearAFROM FuelData
GROUP BYFuelData.YearA;
I've tried the following:
privatefunreadFuelData2(): List<FuelData2>{
var resultList =ArrayList<FuelData2>()
val rowParser = classParser<FuelData2>()
database.use {
select("FuelData AS FuelData1 INNER JOIN FuelData AS FuelData2 On FuelData1.Id = (FuelData2.Id - 1)",
"FuelData1.id, FuelData2.currentDate, (FuelData2.fueled / (FuelData2.mileage - FuelData1.mileage) * 100)"+" AS litersPer100Km")
.parseList(rowParser).forEach {
fuelData -> resultList.add(fuelData)
}
}
return resultList
}
Can this be done via a raw query or something like that?
The text was updated successfully, but these errors were encountered:
SeppPenner
changed the title
Question: How can I do the following queries?
Question: How can I do inner join queries on the same table with SQL aliasses (AS keyword) in Anko-SQLite?
May 11, 2018
I have the following table definition in SQLITE:
How can I perform the following queries (Inner Join on 2 times the same table) in Anko?
I've tried the following:
as described here: https://stackoverflow.com/questions/45912680/select-data-from-two-tables-in-kotlin-anko but this does not work, too.
Can this be done via a raw query or something like that?
The text was updated successfully, but these errors were encountered: