Help with basic SQL SELECT Statement?
-
I was hoping to get some assistance with the query below. I was able to create the individual SELECT statements against the Pubs database in SQL Server 2008 R2, but I am not sure how to join them as one select query so the results come up in one table and not three individual tables: SELECT * FROM stores WHERE state= 'CA' SELECT * FROM sales WHERE payterms='Net 30' SELECT * FROM sales WHERE qty >=’20’ *Any help would be greatly appreciated.
-
Answer:
Don't know if this is exactly right but this is what comes to mind as a start: SELECT state, payterms, qty FROM stores, sales WHERE (state='CA' OR payterms='Net 30' OR qty>='20');
Rob at Yahoo! Answers Visit the source
Other answers
Don't know if this is exactly right but this is what comes to mind as a start: SELECT state, payterms, qty FROM stores, sales WHERE (state='CA' OR payterms='Net 30' OR qty>='20');
Toad
It would help if you had listed the relevant schema, but if you can't do it with a join, perhaps subqueries would work...something like SELECT <whatever> FROM <whatever source tables needed> WHERE sales.store_ID IN (SELECT store_ID FROM stores WHERE state = 'CA') AND (sales.payterms = 'Net 30' AND sales.qty >= 20)
TheMadProfessor
It would help if you had listed the relevant schema, but if you can't do it with a join, perhaps subqueries would work...something like SELECT <whatever> FROM <whatever source tables needed> WHERE sales.store_ID IN (SELECT store_ID FROM stores WHERE state = 'CA') AND (sales.payterms = 'Net 30' AND sales.qty >= 20)
TheMadProfessor
Related Q & A:
- How to write SQL statement with dynamic where clause?Best solution by Stack Overflow
- What is a basic policy statement?Best solution by answers.yahoo.com
- Can someone help me out with my personal statement for job?Best solution by jobs.ac.uk
- I have to write a personal statement. Any help?Best solution by ucas.com
- I really need some help writing my personal statement for a nursing program.Best solution by cmu.edu
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.