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
 Cant do view date

Author  Topic 

peckitt99
Starting Member

1 Post

Posted - 2006-11-23 : 05:31:47
hi am am very new to sql and im finding it really hard to do parts of my assignment.

some of the questions i am struggeling on are

Which employees were hired in March?

Which employees were hired on a Tuesday?


Show details of employee hiredates and the date of their first payday.
(Paydays occur on the last Friday of each month) (plus their names)

Refine your answer to 7 such that it works even if an employee is hired after the last Friday of the month (cf Martin)

can anyone help?

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-11-23 : 05:34:52
Lookup DATENAME / DATEPART in BOL.

Mark
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-23 : 06:50:58
Also Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raghuramgupta
Starting Member

3 Posts

Posted - 2006-11-23 : 07:26:20
Hi, i think i can solve your first query
query:
select ename from employ where hiredate > '03-01-2006' and hiredate <'03-30-2006'



Raghuram Gupta.Sarabu
GGK Tech
Hyderabad
India
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-23 : 07:32:54
quote:
Originally posted by raghuramgupta

Hi, i think i can solve your first query
query:
select ename from employ where hiredate > '03-01-2006' and hiredate <'03-30-2006'



Raghuram Gupta.Sarabu
GGK Tech
Hyderabad
India



I think by March he does not mean only current year, but all those who joined on March of any year.

quote:
Refine your answer to 7 such that it works even if an employee is hired after the last Friday of the month (cf Martin)


I smell homework here !

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-23 : 07:34:51
quote:
Originally posted by raghuramgupta

Hi, i think i can solve your first query
query:
select ename from employ where hiredate > '03-01-2006' and hiredate <'03-30-2006'



Raghuram Gupta.Sarabu
GGK Tech
Hyderabad
India


Why did you omit first and last two days of March?
Why didnt you consider those who joined not in 2006?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-23 : 07:36:03
Half

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-23 : 07:37:48
Really?

1) select * from employees where datepart(month, hiredate) = 3
2) select * from employees where datepart(dw, hiredate) = 3 (or any other value between 1 and 7 that matches your system)
3) select e.*, p.pd from employees e left join (select empid, min(payday) pd from paydays group by empid) w on w.empid = e.employeeid


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-11-23 : 11:04:42
quote:
Originally posted by peckitt99

hi am am very new to sql and im finding it really hard to do parts of my assignment
...
can anyone help?


Read and study your textbook. Do your homework probelms the best you can, and ask your teacher for help with the ones you have trouble with.





CODO ERGO SUM
Go to Top of Page

firefly
Starting Member

5 Posts

Posted - 2006-11-23 : 13:59:44
quote:
Originally posted by Michael Valentine Jones

quote:
Originally posted by peckitt99

hi am am very new to sql and im finding it really hard to do parts of my assignment
...
can anyone help?


Read and study your textbook. Do your homework probelms the best you can, and ask your teacher for help with the ones you have trouble with.





CODO ERGO SUM



I find it amusing when people on the forum give self righteous advice like 'read your textbook, ask your professor, do this, do that' and refuse to release the information one inquired about.

As a student in a very demanding program I know first hand that reading a textbook, re-reading it, and reading it again after that is not the answer to all the questions that may occur in one's mind. Professors are more often than not unavailable outside their office hour scheduled once a week. TAs are terribly unhelpful, I don't know how many I had to ask for help and ended up giving me some terrible excuse as to why they didn't know the answer, or they gave me some memorized answer that they didn't comprehend and thus werent able to expand, or simply because their english is so poor it's beyond comprehension. Add into account that there's about 125 students in my class and realize exactly how much time TAs and prof can allocate to understand and help you solve your question. Which is why they never actually shut up and listen all you have to say in the first place, they always cut you off thinking they understood what you have problems with and end up giving you a 5 min speech about something that's completely remote from your actual question.

So honestly guys, before throwing this kind of condescending garbage on a forum so you feel validated, return to a renowned university and take a full load there.

You will notice that textbooks, the more technical the topic is, the worse and unclear they are. Ask the profs, they will agree to that too. The ask them about what the best book on a topic is...then read it. You will see that for you it won't be the best book. Why because you don't go in reading it with the same amount of information your prof already knows. And nobody has the time or/and the expertise to understand you, find a way to relate to what you know, and help you out.

When seeing questions like this the mature, intelligent way to handle them is to address the concepts and explain them. If adding code to your explanations is too much for you, then just address the concepts relevant to the question and answer. If not, don't bother at all. Posting stuff like 'smells like homework' makes you look like an imbecile seeking aproval.

Do not deny the information to those who seek it. If you don't want to offer it at least offer SPECIFIC GUIDELINES like read book YYY, Chapter XXX, page ZZZ. Or look into concept XXX when KKK happens, or ZZZ condition is met.
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2006-11-23 : 14:48:12
quote:

As a student in a very demanding program I know first hand that reading a textbook, re-reading it, and reading it again after that is not the answer to all the questions that may occur in one's mind.



Get used to it. If you think someone will actually teach you anything at Uni, that is your first mistake. Uni requires YOU to teach yourself.

quote:

So honestly guys, before throwing this kind of condescending garbage on a forum so you feel validated, return to a renowned university and take a full load there.



Boo f$%^$^ hoo! Do you need a tissue with that?

quote:

Posting stuff like 'smells like homework' makes you look like an imbecile seeking aproval.



You didn't actually help the OP in your entire rant.
By your definition, you are also an imbecile...

Welcome to the club..




DavidM

Production is just another testing cycle
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-11-23 : 22:08:12
quote:
Originally posted by firefly
... rant removed...



Your right, I’m a condescending bastard, with little regard for the cruel and inhumane conditions that students have to struggle through in demanding programs at renowned universities.

It’s true; I really don’t care if you pass or fail. In fact, I would prefer that you fail your classes, flunk out, and work the rest of your short, miserable life as the assistant janitor in a second-rate fast food restaurant. The last thing the world needs is another incompetent developer, especially one with a bad attitude and inflated sense of self entitlement.

I feel no particular obligation to help anyone cheat on their homework, especially someone who did little more than cut and paste their homework questions. So if you don’t like my advice, feel free to ignore it. It was the method I used to get through school, and it worked for me, so I think it’s good advice.





CODO ERGO SUM
Go to Top of Page

firefly
Starting Member

5 Posts

Posted - 2006-11-24 : 12:07:42
quote:
Your right, I’m a condescending bastard, with little regard...


And also poor grammar which is really a reflection of the quality education you received, how seriously you took it and how seriously you take yourself. It's funny you talk about good development when you can't even comprehend the rules of a language that you've been speaking since you were born. Trust me it's not that complicated, three years ago I could not even order a pizza.

Besides, assuming that the initiator of this post was trying to cheat and not genuinely look for knowledge is just idiotic. Which follows the trend of the rest of your reasoning really.
Go to Top of Page

SparkByte
Yak Posting Veteran

60 Posts

Posted - 2006-11-24 : 12:57:41
Yea Firefly!!!!

Many of the comments from both Firefly and Michael Valentine Jones have merit as far as doing someone’s homework. As a born in rural Nebraska farm boy, I have seem my share of prejudices against all kinds of people and/or beliefs, but I can’t say I have ever seen it turned on a simple student for asking for some help.

If you can’t remember how frustrating it can be to be given a task that is just past your current experience level, have a deadline to meet and have tried to solve until your head hurts….. Shut up and move on.

Yes, peckitt99 is most like trying to complete a homework assignment and yes this can be solved by going to borders and spending time reading some books on basic SQL.

Peckitt99 did not ask the forum to do the homework assignment. All he/she did was ask for some help.




quote:

Which employees were hired in March?
Which employees were hired on a Tuesday?


These two are the easiest to tackle. In your select statement you are going to need to narrow the amount of data that will be returned by using a where clause like the examples provided by Peso.
quote:

Peso
where datepart(month, hiredate) = 3


This simply narrows the data that will be returned by the select statement to the month of march.

The part of the where that you will need to get some more information on is DATEPART. This is used to defign what date information you need.
quote:

Show details of employee hiredates and the date of their first payday.
(Paydays occur on the last Friday of each month) (plus their names)


A new select getting the EmployeeName, HireDate, and CheckDate(if available).
Here you are going to use some additional date formating to get what you need, but you are still looking at DATE options to narrow your search.
quote:

Refine your answer to 7 such that it works even if an employee is hired after the last Friday of the month (cf Martin)


Not sure how to handle this one, but again it is still a date issue.
I think it would be handled in an IF/THEN.
Maybe someone else can help out here.


Thank You,

John Fuhrman
http://www.titangs.com
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-24 : 13:17:47
Firefly, what you say appears very reasonable, but I want to point out something, that has happened in this thread and happens in most of these threads that you criticise - the OP has not come back and posted any further information. They ask a question that is easily answered from the product documentation (and in the very first response mwjdavidson told the OP exactly where to look), without giving enough info about what they really want, and then don't even have the decency to provide more info when requested, or say thank-you and acknowledge when they have received the answer they needed.

So then you have volunteers who are doing this for nothing wondering if the person ever even bothered to read the response, and you criticise us for not spending enough time to answer the question more fully! Take the time to read a few more threads, like this one for example, and you'll see how dedicated people are to helping those who are often pretty darn difficult to help
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74945
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-24 : 14:16:13
Most often we also see that OP has asked the same question on several forum, hoping this will help him/her faster. That is one of the reasons for not getting back, if question is already answered somewhere else. But the only outcome of this is frustration of having answering a question already answered somewhere else. Many of us then feel that our time and effort can be better spent on people who really need help, rather than giving someone an answer he/she is very capable of creating themself.

My gut feeling here at SQLTeam is that OPs has to put in a little bit of effert themself and post their attempt so far, until posting here. That is not too much to ask for, right? If OP shows shat he/she has first, we can comment and suggest in a far better manner with positive critisicm.

I am not in mood to help freeloaders passing a class, who should not pass under normal circumstances.
I am tired of meeting loosers at my job who only occupies other peoples time and patience, because they are not ready to do some serious SQL work. But they got the position because they could show some degree from some school (which we in most cases helped them to pass) and then only make a lot of mess in the real world.

Brett has some excellent advice how to present their problems here.

1) Present relevant sample data
2) Present the expected output, based on the provided sample data
3) Post the table layout/definitions (DDL) so that more advanced queries are made right the first attempt.

We do not like escalating/advancing question too. The kind that after first post says "Great, but I really have this data instead and this and this...".
We give up. Why bother to help if OP post some bogus question? It only takes double the time, time that can be better spent on someone who better need guidance and advice.

My 25 cent.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-24 : 14:18:10
quote:
Originally posted by snSQL

Take the time to read a few more threads, like this one for example, and you'll see how dedicated people are to helping those who are often pretty darn difficult to help
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74945 height="1" noshade id="quote">
Hey! That's me again


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-11-24 : 16:04:32
quote:
Originally posted by firefly

quote:
Your right, I’m a condescending bastard, with little regard...


And also poor grammar which is really a reflection of the quality education you received, how seriously you took it and how seriously you take yourself. It's funny you talk about good development when you can't even comprehend the rules of a language that you've been speaking since you were born. Trust me it's not that complicated, three years ago I could not even order a pizza.

Besides, assuming that the initiator of this post was trying to cheat and not genuinely look for knowledge is just idiotic. Which follows the trend of the rest of your reasoning really.



Is grammar nitpicking really all you have to say? I won't bother with your grammar errors.

Yes, I am assuming the OP is a homework cheater, because all the evidence points to that. All he did was cut and paste homework questions, not show the work he had attempted, not provide table structures, not ask any specific questions about what he was having trouble with, and not respond to follow-up questions. In other words, classic homework cheater behavior.

I notice that you have offered no help to the OP. If you really feel that he deserves help, you could show that you have more to offer than inflammatory rants.





CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-24 : 16:43:02
OP will not come back for answer. He has his hands full with ladies
http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=62713887


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-11-24 : 17:16:03
quote:
Originally posted by Peso

OP will not come back for answer. He has his hands full with ladies
http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=62713887


Peter Larsson
Helsingborg, Sweden


Four years of college, and only 3 more to go to graduate
Tim's Schools  
University of Central Lancashire
Preston, United Kingdom
Graduated: 2009
Major: Computing Forensics
2005 to Present

Runshaw College
Leyland, United Kingdom
Degree: None
2002 to 2005


Guess he can't ask his friend Stephen for help.
Stephen 
Nov 22 2006 5:26A

i did quite alot of the basic mbs thing but still
doin shit and im well behind on sql



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -