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
 how to get better at writing queries?

Author  Topic 

m1k3m41
Starting Member

9 Posts

Posted - 2013-02-21 : 14:47:11
I am new to SQL programming and just started my first class on databases in January. I find it hard to solve word problems even though I study the material extensively. Examples of questions are:

1) Find the SID of the student whose GPA is greater than that of student whose SID is 233.
2) Find the pharmacy that carries the drug that is most prescribed.

The problems that deal with more than 1 table gets me confused and I don't even know where to begin. I do perfectly fine when it is only involving 1 table. Do you guys have any tips on getting better at solving these problems and what steps I should take? Thank you very much.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2013-02-21 : 18:41:04
Keep reading this forum and see what other people are asking, and try to answer it yourself, and then see what other people did to solve it and try to understand what they did to solve it. You can always ask questions about what somebody did and why. A good first start, at least for me anyway, was to realize what is actually happening in the
SELECT
FROM
WHERE
construct. Did you know that SQL looks at the FROM 1st, the WHERE 2nd and the SELECT last?
I know this isn't much, but I hope it gets you started.

Good luck!

Jim





Everyday I learn something that somebody else already knew
Go to Top of Page

m1k3m41
Starting Member

9 Posts

Posted - 2013-02-25 : 12:56:34
Thanks Jim. So I'm guessing the only way to get better is through practice? I will try to do more problems. I just hope to be able to grasp this concept.. I usually don't know where to begin but once I see the answer, it seems like it was so easy....
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2013-02-25 : 13:02:06
Books are good. I really enjoyed Itzik Ben-Gan's t-SQL Fundamentals. I think it's important to get the fundamentals down early. I didn't do that (self-taught) and taught myself some really stupid things!

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

erikhaselhofer
Starting Member

30 Posts

Posted - 2013-02-26 : 01:20:33
quote:
Originally posted by m1k3m41

Thanks Jim. So I'm guessing the only way to get better is through practice? I will try to do more problems. I just hope to be able to grasp this concept.. I usually don't know where to begin but once I see the answer, it seems like it was so easy....


SQL is art, at least some of it. Sure, there's an underlying logic behind it all, but there's also something that clicks and says, "yeah, I can do that" even if you aren't sure how to do that. And, often, there's more than one way to do something. It makes it fun, at least to me.

My only disagreement with Jim, is that forums can be very hit or miss to learn from. You can get incomplete questions, complex questions that might, or might not be rational, and even the different flavors of SQL aren't consistent. Most people don't straddle the lines between different databases, so maybe that doesn't matter, but they all have different approaches to some things in some places and it can burn you if you aren't careful. However, odds are at your point, you aren't learning anything version specific. That said, they are a great place to see and try things you surely wouldn't have thought up on your own.

Anyways, if I had any advice it would be to try things that look weird, see what happens and always be prepared to be wrong. It'll happen more than once.

Good luck, have fun with it and don't beat yourself up over it.
Go to Top of Page
   

- Advertisement -