| Author |
Topic |
|
ozsql
Starting Member
14 Posts |
Posted - 2009-09-17 : 05:01:40
|
| Hi Guys,This is my first project can anyone help me by providing SQL query, how to generate below questions. They are three questions a,b and c.TblconsignmentJob_no, job_type, book_date, cust_code, depot, revenue, manifestexpensesA) No of Consignments in the table. If NULL represent as ‘unknown’.B) Total revenue on consignmentsC) Total revenue per consignmentThanks,Roman |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-17 : 05:02:57
|
A) use count(*)B) use SUM()C) use SUM() + GROUP BY KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-17 : 05:03:46
|
| What have you tried so far?MadhivananFailing to plan is Planning to fail |
 |
|
|
winterh
Posting Yak Master
127 Posts |
Posted - 2009-09-17 : 06:05:14
|
| A) SELECT count(*), IsNull(Job_Type, 'Unknown')FROM TblConsignmentGROUP BY Job_Type-- Will show how many consignements there has been for each job_type, and null values will be counted under header 'Unknown'.B) and C) as khtan said, use SUM() on B), and SUM() ... GROUP BY() on C.Need any further help then feel free to ask.I would use a temporary table for everything ever |
 |
|
|
ozsql
Starting Member
14 Posts |
Posted - 2009-09-17 : 06:36:10
|
| Thanks Very Much guys !!!!!! |
 |
|
|
winterh
Posting Yak Master
127 Posts |
Posted - 2009-09-17 : 07:04:35
|
| Always feel free to ask for help.I would use a temporary table for everything ever |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-17 : 08:17:12
|
| <<I would use a temporary table for everything ever>>Why?MadhivananFailing to plan is Planning to fail |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-09-17 : 08:24:27
|
quote: Originally posted by madhivanan <<I would use a temporary table for everything ever>>Why?MadhivananFailing to plan is Planning to fail
So he can format it in the front end? [ /fail at humor]http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-17 : 08:39:07
|
quote: Originally posted by madhivanan <<I would use a temporary table for everything ever>>Why?MadhivananFailing to plan is Planning to fail
that's just winterh's signature line. It is not a reply to OP's question KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-17 : 08:40:30
|
quote: Originally posted by DonAtWork
quote: Originally posted by madhivanan <<I would use a temporary table for everything ever>>Why?MadhivananFailing to plan is Planning to fail
So he can format it in the front end? [ /fail at humor]http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-17 : 08:41:00
|
quote: Originally posted by khtan
quote: Originally posted by madhivanan <<I would use a temporary table for everything ever>>Why?MadhivananFailing to plan is Planning to fail
that's just winterh's signature line. It is not a reply to OP's question KH[spoiler]Time is always against us[/spoiler]
Ok. Thanks MadhivananFailing to plan is Planning to fail |
 |
|
|
winterh
Posting Yak Master
127 Posts |
Posted - 2009-09-17 : 09:02:36
|
| It was a quote taken from someone I know. I feel I should change it now. lol. Thanks guys :(I would use a temporary table for everything ever |
 |
|
|
winterh
Posting Yak Master
127 Posts |
Posted - 2009-09-17 : 09:04:35
|
| better?[ /fail at humor] |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-09-17 : 10:58:55
|
| I have been quoted! yay me.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
winterh
Posting Yak Master
127 Posts |
Posted - 2009-09-18 : 07:04:29
|
| :)[ /fail at humor] |
 |
|
|
|