Solved

Select within select

Posted on 2014-04-01
2
247 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now