Solved

Select within select

Posted on 2014-04-01
2
251 Views
Last Modified: 2014-04-01
Select
  name, address, sales
from
  data
where
  sales > 100k

Returns records where sales are greater than 100k.

What if I want to see everyone but only the sales if they are more than 100k:

Select
  name, address, sales if sales > 100k
from
  data

Possible with Pervasive?
0
Comment
Question by:classnet
2 Comments
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 500 total points
ID: 39970750
Do you mean want to show all records and the Sales Values only if greater than 100k?

You can have a case in your select for Sales column to check if its greater than 100k then show sales figure if not show 'NULL' or '' (emtpy string) or '0' (Zero).

Example:

  SELECT    Name ,
            ADDRESS ,
            ( CASE WHEN Sales > 100000 THEN Sales
                   ELSE NULL
              END ) AS Sales
  FROM      Data

Open in new window

0
 

Author Closing Comment

by:classnet
ID: 39970817
Thank you!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question