Sample Queries

Sample Queries

The following table displays the sample queries for the Assets, Timeseries, Timeseries Data Points, Sequences, Relationships, Datasets, and Events table:
Sample Queries
S.No
DataMosaix Resource
SQL Query
1
Asset
SELECT * FROM public.assets WHERE name like 'testasset-37%'   OR name like 'testtraining-%'   OR name = 'test-13 on "asset-1"';
2
Asset
SELECT * FROM public.assets WHERE name IN (   'testasset-37 on "test-1"',   'testtraining-01 on "test-1"',   'asset-13 on "test-1"');
3
Timeseries
SSELECT * FROM timeseries  WHERE externalId LIKE 'ext%';
4
Timeseries
select * from timeseries where name = '<timeseriesName>'
5
Timeseries Data Points
SELECT * FROM public.timeseries_datapoints WHERE timeseriesid = <timeseriesid>; SELECT * FROM public.timeseries_datapoints WHERE externalid = '<externalid>';
6
Timeseries Data Points
select * from public.timeseries_datapoints where (externalid= '<externalid>' AND isstring = '<boolean>' ) OR ( timestamputc BETWEEN '2024-08-26 08:30:49.039' and '2024-05-26 08:30:49.039' AND  valuenumeric > 100)
7
Timeseries and Assets Join
select * from public.timeseries join public.assets on public.timeseries.assetId = public.assets.id;
8
Timestamp Functions (NOW() and CURRENT_TIMESTAMP())
SELECT NOW(); SELECT NOW() - INTERVAL 1 hour; SELECT CURRENT_TIMESTAMP(); SELECT CURRENT_TIMESTAMP() - INTERVAL 1 hour;
9
Sequences
SELECT id, type, createdTime, lastUpdatedTime, externalId, assetId, name, description, dataSetId  FROM public.sequences;
10
Relationships
SELECT * FROM public.relationships WHERE sourceType = 'asset';
11
Datasets
[SELECT * FROM public.dataset WHERE externalId LIKE 'prefix%';]
12
Events
SELECT * FROM public.events WHERE (description LIKE 'P%' OR externalId = 'f8b2de96-39bd-46c7-9c88-bbb949e0e9b2') AND datasetId = 3701037531680276;
13
Datasets (Inner Join)
SELECT d.id, d.name FROM public.datasets d JOIN public.datasets p ON d.externalid = p.externalid;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.