Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Syntax

Posted on 2014-02-20
2
Medium Priority
?
474 Views
Last Modified: 2014-02-20
Hey guys,

I have 2 tables....Trans and TransDetails

I am trying to select the (TransNum)'s from the Trans table where they only have 1 record in the TransDetail table and that record's ProdID is = 111.


Trans
TransNum        FinalTotal
1                        25
2                        15
3                        73
4                        34
5                        98



TransDetails
Unique ID              TransNum            ProdID
1                            1                             111
2                            1                             259
3                            1                             854
4                            2                             111
5                            3                             111
6                            3                             665
7                            3                             811
8                            3                             911
9                            4                             111
10                          4                             654
11                          4                             785
12                          4                             215
13                          4                             614
14                          5                             111

In this example I want the query to return TransNum 2 and 5.


SyBase SQL Anywhere v10
0
Comment
Question by:triphen
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 total points
ID: 39876047
Select Transnum from Trans
where TransNum in ( Select TransNum from TransDetails
Group by TransNum having Count(*) = 1)
0
 

Author Closing Comment

by:triphen
ID: 39876067
You rock!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

927 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