Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 IN Operator in Select Statement

Author  Topic 

dlmagers10
Starting Member

48 Posts

Posted - 2010-10-12 : 01:03:53
Ok, I have a question (problem) I am trying to using the IN operator to find the number and name of each customer that placed an order on October 23, 2010.

Tables ~

rep r has rep_num, last_name, first_name, street, city, state, zip, commission, rate.

customer c has customer_num, customer_name, street, city, state, zip, balance, credit_limit, rep_num.

orders o has order_num, order_date, customer_num.

order_line l has order_num, part_num, num_ordered, quoted_price.

part p has part_num, description, on_hand, class, warehouse, price.

So far I have:

SELECT c.CUSTOMER_NUM, c.CUSTOMER_NAME
FROM CUSTOMER C, orders o
WHERE ORDER_DATE IN
(SELECT o.order_date
FROM orders o
WHERE o.order_date = 10/23/2010);

still just getting the column heads: customer_num, customer_name.

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2010-10-12 : 01:08:42
quote:
Originally posted by dlmagers10

Ok, I have a question (problem) I am trying to using the IN operator to find the number and name of each customer that placed an order on October 23, 2010.

Tables ~

rep r has rep_num, last_name, first_name, street, city, state, zip, commission, rate.

customer c has customer_num, customer_name, street, city, state, zip, balance, credit_limit, rep_num.

orders o has order_num, order_date, customer_num.

order_line l has order_num, part_num, num_ordered, quoted_price.

part p has part_num, description, on_hand, class, warehouse, price.

So far I have:

SELECT c.CUSTOMER_NUM, c.CUSTOMER_NAME
FROM CUSTOMER C, orders o
WHERE
c.customer_num= o.customer_num and
o.ORDER_DATE IN
(SELECT o.order_date
FROM orders o
WHERE o.order_date = 10/23/2010);

still just getting the column heads: customer_num, customer_name.



where is join bw orders table & customers table
Go to Top of Page

dlmagers10
Starting Member

48 Posts

Posted - 2010-10-12 : 01:19:45
I am hearing ya but I am getting the same output. It has the results as just the column names. You are right though I did not have my join. Thank you for bringing that to my attention. I will work on this tomorrow. It is getting late.

Thanks again.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-12 : 02:20:18
Please don't cross post. It just wastes peoples time and fragments replies.

No replies to this thread please. Direct replies to: [url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151418[/url]

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -