Hello All,
I am working with SAP HANA tables and I have a problem in writing the query to get selected records from the table which has >1 million records. The following is the brief SQL query for the table:
SELECT
"MEASURINGDOC",
"READ_DATE",
"MEASURING_READ",
"MESURING_POINT",
FROM "MEASURING_DOCUMENTS"
Each "MESURING_POINT" has multiple "MEASURINGDOC" entries with the readings taken on "READ_DATE" and values recorded as "MEASURING_READ". Each "MESURING_POINT" has a frequency period in which the Readings are taken. Some are weekly, some are monthly, some are quarterly and some are taken when investigating a problem.
From the above table I want to create a query to take out the most recent 10 "MEASURING_READ" for each "MEASURING_POINT". This is to plot a chart for each "MESURING_POINT", the "MEASURING_READ"s over a period of time.
As the time intervals are different for each "MEASURING_POINT", I cannot use the "READ_DATE" for all "MEASURING_POINTS" to filter the results.
I think we may have to use UNION query, but my knowledge of SQL is limited.
Will the experts suggest a solution?
Thank you in advance
krishna