Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

tsql code Expand / Collapse
Author
Message
Posted Friday, July 6, 2012 10:12 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 22, 2013 9:00 PM
Points: 2, Visits: 18
Imagine a table which contains records for all weekly number of bugs
discovered by each QA analysts in the team for one year. Please describe a
simple SQL statement for identifying a winner (an employee who found the
biggest number of bugs during that year) by writing one statement?
Post #1326381
Posted Saturday, July 7, 2012 1:36 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:49 PM
Points: 1,037, Visits: 7,026
debris_flow (7/6/2012)
Imagine a table which contains records for all weekly number of bugs
discovered by each QA analysts in the team for one year. Please describe a
simple SQL statement for identifying a winner (an employee who found the
biggest number of bugs during that year) by writing one statement?


This is a simple exercise made difficult by having to imagine what the table and data look like. Read the link in my sig "please read this" and provide DDL for the table and DML for some sample data.
Otherwise you may have to imagine what the simple SQL statement might look like



Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




Understanding and using APPLY, (I) and (II) Paul White

Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Post #1326397
Posted Saturday, July 7, 2012 7:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 22, 2013 9:00 PM
Points: 2, Visits: 18
Thank you very much for your suggestion
Post #1326419
Posted Saturday, July 7, 2012 1:15 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:11 PM
Points: 35,772, Visits: 32,441
debris_flow (7/6/2012)
Imagine a table which contains records for all weekly number of bugs
discovered by each QA analysts in the team for one year. Please describe a
simple SQL statement for identifying a winner (an employee who found the
biggest number of bugs during that year) by writing one statement?


This is a terrible homework problem. It doesn't tell you what to do if there's a tie.

Some hints to solve this (and there are many different ways). Lookup the following in Books Online.

GROUP BY
SUM()
MAX()
ORDER BY
COMMON TABLE EXPRESSIONS (CTEs)
RANK()/DENSERANK()
ROW_NUMBER()


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1326479
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse