Solved

SQL Syntax

Posted on 2014-02-20
2
463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

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

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 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