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

  • Home
  • SEARCH
  • 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 6171951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:18:34+00:00 2026-05-23T23:18:34+00:00

I have a simple select with one inner join query. However when I create

  • 0

I have a simple select with one inner join query. However when I create a view with the same code, the results are different. I am not pulling data from views. It is all user table based.

QUERY:

SELECT DISTINCT TOP 100 
dbo.table1.a1,
dbo.table1.a2,
dbo.table2.something_else  FROM dbo.table1 inner join 
dbo.table2 ON 
dbo.tabel1.a1 = dbo.table2.somethingelse
WHERE dbo.table.a2 = '1'
ORDER BY dbo.table.a1 DESC

VIEW:

CREATE VIEW TEST
AS

SELECT DISTINCT TOP 100 
dbo.table1.a1,
dbo.table1.a2,
dbo.table2.something_else  FROM dbo.table1 inner join 
dbo.table2 ON 
dbo.tabel1.a1 = dbo.table2.somethingelse
WHERE dbo.table.a2 = '1'
ORDER BY dbo.table.a1 DESC

When I compare the results of the Query to the View, they appear to be different. The VIEW has more result then the query and the order is not the same (due to more records in the VIEW than query.) Its the same code, so how can it be different?

  • 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-23T23:18:35+00:00Added an answer on May 23, 2026 at 11:18 pm

    Generally speaking, ORDER BY and related statements are not allowed in view creation. Simply put, the results are returned in an undefined order from a view. This is probably why you’re also not restricting to the top 100 rows, because the rows aren’t ordered.

    Pull out your ordering and rowcount into the statement that selects from the view, and see if that works.

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

Sidebar

Related Questions

I have a simple SQL 'Select' query, and I'd like to dump the results
Have follow query: SELECT tbl_yaca_sites.`id_site` FROM `tbl_yaca_sites` INNER JOIN `tbl_relation` ON tbl_relation.id_website = tbl_yaca_sites.id_site
I am totally new to SQL . I have a simple select query similar
I have a simple query like this: select * from mytable where id >
I have a super-simple query in a star schema. One fact, two dimensions. I
I can't think through this one. I have this query: SELECT p.person_id, p.first_nm, p.last_nm,
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a relatively simple select statement in a VB6 program that I have
I have simple regex \.*\ for me its says select everything between and ,
I have a simple query that relies on two full-text indexed tables, but it

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.