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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:04:52+00:00 2026-06-13T20:04:52+00:00

Using a view in SQL Server 2000 Table1 : id z1 z2 z3 z4

  • 0

Using a view in SQL Server 2000

Table1:

id  z1      z2      z3      z4   type
--------------------------------------
01A 300     400     300     400  01
2B  300     400     300     400  02
3C  500     300     400     300  01
04A 500     400     500     400  01
05B 400     300     400     300  02
06  150     200     200     150  03
....

Table2:

type  Formula1           Formula2
------------------------------------    
01    ((Z1+Z2)/1000)*2   null
02    null               ((Z3+Z4)/1000)*2
03    ((Z1+Z2)/1000)*2   ((Z3+Z4)/1000)*2

I want to select the table1 rows based on table2 formula:

  • in table2 type – 01 (z1 and z2 found) then i want to consider table1 z1 z2 columns
  • in table2 type – 02 (z3 and z4 found) then i want to consider table1 z3 z4 columns
  • in table2 type – 03 (z1, z2, z3 and z4 found) then i want to consider table1 z1, z2, z3 z4 columns

Expected output

Table1:

id   z1     z2     z3     z4    type
-------------------------------------    
01A  300    400    null   null  01
2B   null   null   300    400   02
3C   500    300    null   null  01
04A  500    400    null   null  01
05B  null   null   400    300   02
06   150    200    200    150   03

Currently I’m using a view, I don’t want to change to stored procedure because most of the report are using this view.

How to do it in sql..?

  • 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-13T20:04:53+00:00Added an answer on June 13, 2026 at 8:04 pm

    Is this what you need? Query works in SQL Sever 2005, donno about 2000, please check:

    select a.ID,
      (CASE WHEN PATINDEX('%Z1%', ISNULL(b.Formula1,'')+ISNULL(b.Formula2,''))<>0 THEN a.Z1 ELSE NULL END) Z1,
      (CASE WHEN PATINDEX('%Z2%', ISNULL(b.Formula1,'')+ISNULL(b.Formula2,''))<>0 THEN a.Z2 ELSE NULL END) Z2,
      (CASE WHEN PATINDEX('%Z3%', ISNULL(b.Formula1,'')+ISNULL(b.Formula2,''))<>0 THEN a.Z3 ELSE NULL END) Z3,
      (CASE WHEN PATINDEX('%Z4%', ISNULL(b.Formula1,'')+ISNULL(b.Formula2,''))<>0 THEN a.Z4 ELSE NULL END) Z4, 
      b.* 
    From TABLE1 a inner join TABLE2 b on a.type=b.type
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to upload image URL in SQL server and retrieve in grid view using
I am using SQL Server 2000 and feeling stuck about how to do this:
I´m using Delphi 5 with SQL Server 2000 here. I have created an ADOQuery
I'm using MS Query Analyzer (as part of SQL Server 2000) to write T-SQL
I am learning how to create view using SQL server. I am trying to
Does anyone have experience with using indexed view in MS SQL Server 2008? I
I'm currently using SQL 2000 (it's a vendor server - don't ask...), and I'm
I'm using ASP.net membership system with SQL Server 2000 database. What I want to
I am using SQL Server 2008 Enterprise. I have yearly customer data from 2000
I am using SQL Server 2000 and I have two databases that both replicate

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.