Quantcast
Channel: SQL Server Reporting Services, Power View Forum
Viewing all articles
Browse latest Browse all 4035

How do I run sub queries on a Dataset?

$
0
0

Hi Guys,

I have a dataset which could potentially be fairly large depending on the date range that the user selects, so Id prefer to run it only once, and get my results from that...

This dataset will mainly be composed of dates and I have to get the average time between dates. ie

dsMain Results

Company, Contact, Posting_Date, Matched_Date, Sent_Date, Interview_Date, etc...
Company, Contact, Posting_Date, Matched_Date, Sent_Date, Interview_Date, etc...
Company, Contact, Posting_Date, Matched_Date, Sent_Date, Interview_Date, etc...
Company, Contact, Posting_Date, Matched_Date, Sent_Date, Interview_Date, etc...
etc...

Most of my Subqueries would need to get the average date between dates

The query below is what I use in SQL to get the difference between Average Matched_date and Average SENT_DATE

SubQuery

(Select DATEDIFF(Hour, CAST(AVG(CAST(MATCHED_DATE AS FLOAT)) AS DATETIME), CAST(AVG(CAST(SENT_DATE AS FLOAT)) AS DATETIME))
From #tbl
Where (Matched_Date is not null and Matched_Date <> '')
  AND (Sent_Date is not null and Sent_Date <> '') 
  AND Company_Name IN ('COMPANYNAME')) AS "CompanyName",

I spent ages trying to convert this subquery to an expression, but it doesnt look like expressions allow the CAST function.

Thanks in advance.


Viewing all articles
Browse latest Browse all 4035

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>