Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Syntax

Posted on 2014-02-20
2
Medium Priority
?
470 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 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

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…
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

730 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