I have two queries that return a single value, from different tables (and not joined via a relationship in any way), and I'm trying to combine both queries' outputs onto a single row, however I'm getting a syntax error. This is what I'm trying:
SELECT
(SELECT Timestamp As StartDate
FROM Events
WHERE Description = 'Inserted') AS StartDate,
(SELECT TOP (1) Timestamp As EndDate
FROM DataStore
ORDER BY Timestamp DESC) AS EndDate
And this is what I'm getting back:
There was an error parsing the query. [ Token line number = 2,Token line offset = 2,Token in error = SELECT ]
Query 1 on its own returns: "2015-06-10 11:43:34.000" and Query 2 returns: "2015-06-11 13:59:47.000"
I want to return a single row with two columns, with the output of query 1 as the "StartDate" column, and the output of query 2 as the "EndDate" column.
SQL CE does not support nesting SELECT statments like this, so you have to use two SELECT statements and use UNION or call ExecuteNonQuery twice.