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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:46:29+00:00 2026-05-21T08:46:29+00:00

Alright, so I have a table that I need to store in a database.

  • 0

Alright, so I have a table that I need to store in a database. The table is in the following format:

Value  | No Deductible | $100 | $250 | $500 |
=============================================
$20000 |          $122 |  $61 |  $28 |  N/A |
$30000 |          $183 | $117 |  $67 |  $44 |

To make it normalized and easily accessible, the table will be in the following format in the SQL Server database:

Value (PK)  | Deductible (PK) | Cost |
======================================
     $20000 |              $0 | $122 | 
     $20000 |            $100 |  $61 |  

The Value and Deductible columns are a joint primary key, preventing duplicates. Additionally there will be a constraint only allow certain deductible values.

Now, this format is perfect for accessibility, but it’s obviously not easy to insert data into. I don’t have immediate plans to build a logical front end for it, so a view in this scenario would be ideal. However, my attempts to produce a view that I can easily edit have failed.

Try 1

SELECT 
    t1.Value, t2.Cost AS [No Deductible], 
    t3.Cost AS [$100], t4.Cost AS [$250], t5.Cost AS [$500]
FROM  Valuation AS t1 
INNER JOIN Valuation AS t2 ON t1.Value = t2.Value 
INNER JOIN Valuation AS t3 ON t2.Value = t3.Value 
INNER JOIN Valuation AS t4 ON t3.Value = t4.Value 
INNER JOIN Valuation AS t5 ON t1.Value = t5.Value
WHERE  
    (t2.Deductible = 0) AND (t3.Deductible = 100) 
    AND (t4.Deductible = 250) AND (t5.Deductible = 500)  

This doesn’t work because you can’t modify multiple base tables.

Try 2

SELECT Value, 
   (SELECT Cost FROM Valuation WHERE Deductible = 0) AS [No Deductible],
   (SELECT Cost FROM Valuation WHERE Deductible = 100) AS [$100],
   (SELECT Cost FROM Valuation WHERE Deductible = 250) AS [$250],
   (SELECT Cost FROM Valuation WHERE Deductible = 500) AS [$500]
FROM Valuation 
GROUP BY Value

You can’t modify calculated columns, either.

Is there an elegant solution to this problem? Perhaps something with unions? I feel like the only solutions I have now are to produce multiple views for each deductible, keep the original table layout (a possibility but not preferred, as the value/deductible key is used as a foreign key in other tables) or just invest the time into creating the logical front end to simulate the table (which, as I said, I would prefer to do later).

  • 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-21T08:46:30+00:00Added an answer on May 21, 2026 at 8:46 am

    First another choice for the query would be:

    Select Value
        , Min( Case When Deductible = '0' Then Cost End ) As [No Deductible]
        , Min( Case When Deductible = '100' Then Cost End ) As [$100]
        , Min( Case When Deductible = '250' Then Cost End ) As [$250]
        , Min( Case When Deductible = '500' Then Cost End ) As [$500]
    From Valuation
    Group By Value
    

    However, this will not enable the view to be updateable. The only way to make it updateable is to add a InsteadOf trigger that will re-normalize the inputted rows in the view structure back to their normalized storage format.

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

Sidebar

Related Questions

Alright, currently I have my SWF hitting a php file that will go and
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Is it alright to expect that the user using the back end will have
Alright so I have this C++ image capturing class. I was wondering if I
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright...I've given the site a fair search and have read over many posts about
Alright, I'm trying to read a comma delimited file and then put that into
Alright. Lets say i have a UITextField where a user can input an url

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.