Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 535771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:45:07+00:00 2026-05-13T09:45:07+00:00

I have quite complicated query from which I would like to create a view.

  • 0

I have quite complicated query from which I would like to create a view. The query looks like this:

select s.avg as c3, fs.bayes, fs.sure, fs.visu, fs.fstd from 
(
SELECT  AVG(q.c3), COUNT(q.c3), q.std
FROM    (
        SELECT  std, c3, ROW_NUMBER() OVER (PARTITION BY std ORDER BY id) AS rn
        FROM    ssims
        WHERE   obraz = 'peppers2' and noisetype ='L' and data>'2009-12-23' and maska = 9
        ) q
WHERE   rn <= 15
GROUP BY
        std
        ) s
,(
SELECT  AVG(f.bayes) as bayes, AVG(f.sure) as sure, AVG(f.visu) as visu, COUNT(f.bayes) as fcount, f.std as fstd
FROM    (
        SELECT  std, bayes, sure, visu, ROW_NUMBER() OVER (PARTITION BY std ORDER BY id) AS rn
        FROM    falki_ssim
        WHERE   obraz = 'peppers2' and noisetype ='L'
        ) f
WHERE   rn <= 15
GROUP BY
        std
        ) fs
where s.std = fs.fstd

It selects me averaged results of the tests with specified parameters. The output of this query returns 10 rows (std values from 5 to 50 with step 5, so 5, 10, 15…) and 5 columns: c3, bayes, sure, visu, std

But I would like to be able to change the obraz and noisetype field for both sub-queries. So after creating such view I would like to be able to select results in this way:

select * from my_view where obraz='peppers2' and noisetype = 'L'

How to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:45:07+00:00Added an answer on May 13, 2026 at 9:45 am

    I’ll have to test it to get the exact query right, but the basic idea is to include obraz and noisetype in your select queries and your group by clauses. Something like this:

    select s.obraz, s.noisetype, s.avg as c3, fs.bayes, fs.sure, fs.visu, fs.fstd from 
    (
    SELECT  obraz, noisetype, AVG(q.c3), COUNT(q.c3), q.std
    FROM    (
            SELECT  obraz, noisetype, std, c3, ROW_NUMBER() OVER (PARTITION BY obraz, noisetype, std ORDER BY id) AS rn
            FROM    ssims
            WHERE   data>'2009-12-23' and maska = 9
            ) q
    WHERE   rn <= 15
    GROUP BY
            obraz, noisetype, std
            ) s
    ,(
    SELECT  obraz, noisetype, AVG(f.bayes) as bayes, AVG(f.sure) as sure, AVG(f.visu) as visu, COUNT(f.bayes) as fcount, f.std as fstd
    FROM    (
            SELECT  obraz, noisetype, std, bayes, sure, visu, ROW_NUMBER() OVER (PARTITION BY obraz, noisetype, std ORDER BY id) AS rn
            FROM    falki_ssim
            ) f
    WHERE   rn <= 15
    GROUP BY
            obraz, noisetype, std
            ) fs
    where s.std = fs.fstd AND s.obraz = fs.obraz AND s.noisetype = fs.noisetype
    

    You should also the JOIN keyword to join tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quite complicated HTML/CSS layout which I would like to convert to
I have a quite complicated query which will by built up dynamically and is
I have here a quite complicated loop what I would like to modify while
OK I have this query that groups 2 columns together quite nicely: SELECT search_query_keyword,
This is probably quite trivial but.... I have a quite complicated linq query that
I have a SQL statement, select ColumnName from Table And I get this result,
This is a more general question: I have a quite complicated files table in
That sounds complicated, doesn't it... actually it's quite easy: I have a multi-language app
I have quite big document in html format that generated from Microsoft Word. It
I'm back with another (possibly) silly question. sorry. I have a pretty complicated query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.