SQL Query questions and answers

Member_2_7966113
Member_2_7966113 used Ask the Experts™
on
Hello Experts,

Can someone let me know if there is a repository where I can lots of SQL Queries with answers?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Distinguished Expert 2018

Commented:
I'm not sure what you are asking.

There is a LOT of answered questions here if you look through the Topic Areas.

If you are looking for some sort of exam prep for SQL, there are a few if you Google around.

SQL also varies from database to database.  What database are you interested in?

Author

Commented:
Sorry for the badly worded question.

I’m looking for repository of SQL queries with answers to the queries.

As regards industry, I looking for sql queries in hospitality eg NHS


Thanks
Most Valuable Expert 2012
Distinguished Expert 2018

Commented:
Sorry but that doesn't help clear things up.

These mean the same thing:
"repository where I can lots of SQL Queries with answers?"
and
"repository of SQL queries with answers to the queries"

I do not know what you are looking for.

So browsing the SQL Topic Area here for answered questions isn't what you are wanting?

Click on Browse, then Solutions.  There you can select the Topic:
https://www.experts-exchange.com/searchResults.jsp?rtid=10&sort=10_-1&searchDisplayTypeID=1&searchTitle=&searchRow=1&clauseTypeId1=70&searchInclude1=true&questionStatusId1=40&searchTopicId=522769

>>As regards industry, I looking for sql queries in hospitality eg NHS

I didn't ask for industry.  I asked for the database product you wanted this SQL for.  Each database product has its own unique tweaks to the ANSI standard.

I also have no idea what NHS means.
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

PortletPaulEE Topic Advisor
Most Valuable Expert 2014
Awarded 2013

Commented:
Judging by former questions from Member_2_7966113 the database might be Microsoft SQL Server. Occasionally SQL Server users refer to that database by the abbreviation  "SQL" and assume we know what that means.

SQL became a standard of the American National Standards Institute (ANSI) in 1986, ...

Despite the existence of such standards, most SQL code is not completely portable among different database systems ...
Wikipedia/SQL

The reason why we ask to know "which database?" is because the syntax needed in (say) MS SQL Server is very different to PostgreSQL or Oracle etc. nb: The tag "SQL" does NOT indicate MS SQL Server.

---------------
@slightwv
If I see "NHS" I think of "National Health System" in the UK.  It could mean "National Highway System", but I believe it is more likely to be the former.
Geert GOracle dba
Top Expert 2009

Commented:
the querries are questions for the database
the answers are what the database returns as data

the answers will differ depending on what data is in the database ...
Geert GOracle dba
Top Expert 2009

Commented:
NHS = Not a Heating System ?

Author

Commented:
Really sorry guys .. I tend to think everyone at EE lives in England @-)

NHS, means National Health Service.

So, let me try again and explain what I'm looking for with examples.

There is a book called Query Answers with SQL Server. Each chapter in that book has a query and an answer to the query, however the book relates to car industry. If you take a look inside the book from Amazon you will see what I mean https://www.amazon.co.uk/Query-Answers-SQL-Server-Depth-ebook/dp/B07DVVGFL7/ref=sr_1_1?ie=UTF8&qid=1539681984&sr=8-1&keywords=query+answers+with+sql+server+volume+ii+in+depth+querying

I looking for something similar pertains to the Healthcare industry. As I couldnt find a book I was hoping that someone from EE could point me to link with a library of various SQL Queries and Answer to  various industries including the Healthcare industry.

Does that make sense?
PortletPaulEE Topic Advisor
Most Valuable Expert 2014
Awarded 2013

Commented:
Good luck locating such a specific book.

(I'm currently thinking of little britain... Margroot, do we have a purple pirate game for 14 year olds?)

Most texts will stick to "generic" topics in the expectation you can extrapolate to your own situation.
Most Valuable Expert 2012
Distinguished Expert 2018

Commented:
Personally, I wouldn't spend money on that book.  They rely way too much on inline views that hit the same base tables used in the outer query.

Many of those can be rewritten to take advantage of WINDOW functions and only access the tables once.

That said:
I understand the desire to learn SQL in a filed where you will be applying it but data is data is data.  SQL to access the data is SQL.

Learning how to compute average repair costs on a Ferrari should be pretty much the same as computing the average cost of a heart transplant.  Except the Ferrari is cheaper...  ;)

Author

Commented:
Slightwv you make a good call comment.

Therefore, do you of any links to any databases that I can download and practice on?

Thanks
Most Valuable Expert 2012
Distinguished Expert 2018

Commented:
Oracle and SQL Server both have free versions.

MySQL is free.

I cannot say for sure but I would bet most products also have them.

Oracle Express Edition:
https://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html

SQL Server Express:
https://www.microsoft.com/en-us/sql-server/sql-server-editions-express

Oracle also has a pretty liberal development and education license if the Express Edition doesn't have a component you wish to experiment with.  For basic SQL, it should be fine.

Author

Commented:
Hi Slightwv, I don’t I made myself clear.

I meant sample databases like a sample sales, marketing etc database of tables that I can download and attach to my SQL server and run queries on.

Does that make sense?
Most Valuable Expert 2012
Distinguished Expert 2018
Commented:
Sorry but I don't know SQL Server.

Oracle has several sample schemas you can install:  HR, OE, PM, IX, and SH.
https://docs.oracle.com/database/121/COMSC/installation.htm

A quick Google points me to a WideWorldImporters  and AdventureWorks samples for SQL Server:
https://docs.microsoft.com/en-us/sql/samples/sql-samples-where-are?view=sql-server-2017

Author

Commented:
Thanks slightwv

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial