How to display only few columns of a table based on the data

Consider the table below

 Name partno.  sch_date    WO#   owed panels  
  aa   1234     08/22/2017  121   22    26  
  aa   1234     08/22/2017  222   22    27  
  aa   1234     08/22/2017  242   22    27  
  aa   1234     08/29/2017  152   20    24  
  aa   1234     08/29/2017  167   20    24  
  aa   1234     08/29/2017  202   20    26  


Is it possible to display the data in such way that when i read through the data if the first partno. in the table has the number of panels greater than owed, then i don't won't to dispaly the other partno. schedule on the same date(sch_date).

Expected Result

  Name partno.  sch_date    WO#   owed panels  
    aa   1234     08/22/2017  121   22    26  
    aa   1234     08/29/2017  152   20    24
more ▼

asked Aug 11 at 07:28 AM in Default

avatar image


@Saaharjit To answer your question literally: yes, it is possible. The question appears to be a homework question, and if so then please show what you have tried so far. Also, the question definition is ambiguous as it is not clear exactly which records needs to be shown. For example, for partno / sch_date combination of 1234 / 08/22/2017 there are 3 records where panels > owed. In this case, which one of the 3 records should be included in the result? The answer that the first record should be included is not sufficient as there is no way of knowing (from question definition) which one of the record is considered first. Please clarify.

5 days ago Oleg
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: 6 days ago

Seen: 16 times

Last Updated: 5 days ago

Copyright 2017 Redgate Software. Privacy Policy