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 7721507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:56:31+00:00 2026-06-01T03:56:31+00:00

I have a view in SQL Server 2008 that I want to use for

  • 0

I have a view in SQL Server 2008 that I want to use for a report in SSRS 2008.

The main problem is that I have to use two different datasets in one table and cannot do grouping as I want it. Both datasets come from this view. Let’s say in one column of my report table I want to sum all computers of all school buildings of my country. In the other column, the ratio students of schools per computer.

Now, in DB there are two different tables one for Buildings and one for Schools (because sometimes there are different buildings for one school or other similar scenarios). Joining them results in more couples building-school than needed for the computer-sum column, it will result summing different times the same building (if more than one schools operate in that building).

The table is this:

enter image description here

To avoid this I have done those two datasets, one from the building point of view, and one from the school point of view. But these are two datasets in one table! To solve my problem, I have thought to add a special column to my view : it checks automatically if a BUILDING_ID is shown twice or more in the result table, f.e. like this:

enter image description here

The problem is that I don’t know if this is possible and if it is, I don’t know 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-06-01T03:56:33+00:00Added an answer on June 1, 2026 at 3:56 am

    Maybe this can give you a hint:

    select building_id, 
    row_number() over (partition by building_id order by newid()) - 1 check_if_previous
    from yourtable
    

    If you just want 1’s or 0’s

    select building_id, 
    cast(row_number() over (partition by building_id order by newid()) - 1 as BIT) check_if_previous
    from yourtable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL Server Reporting Services (SSRS) report, that uses a view. That
I have a view in a SQL Server 2008 db that simply exposes about
I have a view defined in SQL server 2008 that joins 4 tables together.
I have a view in SQL Server 2008 with several columns that are expressions
I use SQL Server 2008 Express with Advanced Services. I have a view: IF
I'm using SQL Server 2008 and I have a view that looks like this:
I have a problem in SQL Server 2008 Reporting Services. The problem is that
I currently have this statement in my SQL View (SQL Server 2008 R2) which
I have a MS SQL view that I want to make available as a
I'm using SQL Server 2008. I have a database table that looks like this

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.