impossible to create a select query with sub select ?


Author
Message
DL9442
DL9442
Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)
Group: Forum Members
Posts: 5, Visits: 17
Hello,

I would have liked to create the following query to get an http response time distribution  

SELECT 'bigger than 3sec', count(*) as nbrequestbelowtime, (SELECT count(*) as nb_of_request_total FROM CurrentView where cs-uri LIKE '%/suite/sites/cpr%') as total
FROM CurrentView
where cs-uri LIKE '%/suite/sites/cpr%' AND time-taken > 3000;

but after a while i get the following error

 ---- Query Failed ----

Unable to interpret SELECT statement. Field, function, or expression expected.

What could be wrong with this query ?


Replies
DL9442
DL9442
Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)Junior Member (51 reputation)
Group: Forum Members
Posts: 5, Visits: 17
If i execute the subselect alone, i get the following result 

+---------------------+
| nbabovetime | total |
+---------------------+
| 21912   | 27061 |
+---------------------+

and if i try to extract the percentage with a outer select

SELECT nbabovetime,total, CAST(ROUND(100.0 * (nbabovetime / total), 2) AS DECIMAL) as Percent
FROM(
  SELECT sum(isrequestabovetime) as nbabovetime , count(*) as total
  FROM (
   SELECT CASE WHEN time-taken > 1000 THEN 1 ELSE 0 END AS isrequestabovetime,cs-uri FROM CurrentView WHERE cs-uri LIKE '%/suite/webapi/%'
  )
);

i get the Error in ROUND: 100.0 is not a valid value for Double.


Trying different other notations for 100.0 (100,0 or 100 since in Belgium we use different characters to separate decimals)     gives 

Function ROUND expects parameter 0 to be of type System.Decimal.






LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
What version of LogViewPlus are you using?  I am not able to recreate the problem locally:



I think this might be an issue with culture localization (this post might be a similar issue).  The first error message you reported does not come from LogViewPlus, but the second one does. 
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
Just a quick note to let you know that we have now released LogViewPlus v3.0.24 as a BETA release. 

This release addresses SQL issue discussed above which was related to localization.  The fix was relatively straight-forward, but unfortunately the change was bundled with a lot of other changes which needed additional testing before we could release.  We would have liked to fix this one faster - apologies for the delay.

This release also adds the ability to embed a subquery statement into select field.  The original SQL statement you posted should now be valid.

Thanks again for bringing this issue to our attention. Please do let me know if you have any further questions or issues.

Toby
Edited 2 Years Ago by LogViewPlus Support
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Login

Explore
Messages
Mentions
Search