Where are TFS Warehouse tables and how to access them directly? - sql-server-2008

I want to access warehouse of tfs to access the tables like
1)table that stores the code requests submitted,approved,rejected
2)table that stores which employee submitted the code or which team sumitted the code on
what date the code is submitted
3)table that stores th e bugs raised,bugs which are open,bugs closed,bugs priority(p0,p1,p2,p3) and some other details
i want the output in the form as below
date bugsClosed bugsOpen Reason
p0 p1 p2 p3 total p0 p1 p2 p3 total Active Fixed Postponed ByDesign ByRepro total
Jan 2 3 4 1 10 4 8 2 10 24 5 6 4 9 0 24
Feb 2 3 4 1 10 4 8 2 10 24 5 6 4 9 0 24
Mar 2 3 4 1 10 4 8 2 10 24 5 6 4 9 0 24
Apr 2 3 4 1 10 4 8 2 10 24 5 6 4 9 0 24
May 2 3 4 1 10 4 8 2 10 24 5 6 4 9 0 24
Jun 2 3 4 1 10 4 8 2 10 24 5 6 4 9 0 24
Thanks & Regards,
Srinivas P.

Start here... it will guide you to your answer.
http://msdn.microsoft.com/en-us/library/ms244696(v=vs.90).aspx
and here for a walk-through of the schema
http://msdn.microsoft.com/en-us/library/ms244711(v=VS.90).aspx
and here for writing custom reports on schema
http://msdn.microsoft.com/en-us/library/bb649552(v=VS.90).aspx

Related

Selecting or Updating with 2 group criteria for a max value on mysql [duplicate]

This question already has answers here:
SQL select only rows with max value on a column [duplicate]
(27 answers)
Closed 3 years ago.
I'm trying to figure out how to use group and max() on joins correctly, I'm doing some parsing of a moodle(Open source school software) mysql database. Students are allowed to retake the quizes indefinatly for this particular program, but I need to be able to update the course completion date to reflect the last time they took the test because a lot of other things depend on the completion fields.
The mdl_quiz_attempts table stores all attempts for all quizes, the userid will have many of the same entries, but the attempt number is not unique to the table, but instead unique to both the student AND the key for the row. Meaning students have multiple entries. On the mdl_course_modules table, The instance field is the key for the mdl_quiz table, and the mdl_course_modules_completion coursemoduleid field is the key for mdl_course_modules.
So what I want to do is this:
given a student id
UPDATE mdl_course_completion.timemodified to mdl_quize_attempts.timemodified
WHERE the row on mdl_quiz_attempts is the max attempt by userid for each quiz.(the quiz field on the quiz_attempts has to be looked up through in course module instance table to get the, instance id for course completion module id)
Here are example partial tables.
mdl_quiz_attempts
id quiz userid attempt timemodified
2 1 3 6 1365408901
6 1 4 1 1369873688
7 2 4 1 1369877532
8 7 4 1 1369881431
9 7 4 2 1369882897
12 5 4 1 1505165504
13 6 4 1 1369887643
17 8 4 1 1369958105
18 1 4 2 1374557701
22 7 4 3 1374639901
23 6 4 7 1374640202
24 5 4 2 1374639901
25 8 4 2 1374639901
26 2 4 2 1374639301
27 2 6 1 1376620469
29 2 12 1 1389915486
30 1 23 1 1390978667
31 1 23 2 1391030924
32 2 23 1 1392113103
33 2 23 2 1392696602
34 2 23 3 1392767435
35 7 12 1 1398914256
36 8 43 1 1405281193
37 1 50 1 1405522411
38 5 43 1 1505165504
mdl_course_modules
id course module instance section
3 2 9 2 3
5 2 17 2 4
7 2 17 3 5
8 2 17 4 6
9 2 17 5 7
10 2 17 6 8
11 2 17 7 9
12 2 17 8 10
13 2 17 9 11
14 2 17 10 12
15 2 17 11 13
25 2 16 1 14
26 2 23 1 4
28 2 7 1 14
30 4 9 4 26
42 4 23 3 33
45 4 23 6 38
46 4 23 7 37
47 4 23 8 36
48 4 23 9 35
49 4 23 10 32
50 4 23 11 34
51 5 9 5 27
53 5 23 12 43
55 5 23 13 44
mdl_quiz
id name
10 Unit 10 Quiz
11 Unit 2 Quiz
12 Unit 3 Quiz
13 Unit 5 Quiz
14 Unit 1 Quiz
15 Unit 8 Quiz
16 Unit 9 Quiz
17 Unit 7 Quiz
18 Unit 4 Quiz
mdl_course_modules_completion
id coursemoduleid userid completionstate viewed timemodified
14 25 2 0 1 0
15 25 6 0 1 0
67 25 4 1 1 1369873688
68 28 4 1 0 1369874483
69 192 4 1 0 1369875233
70 184 4 1 1 1369877532
Something like this ?
update mdl_course_modules_completion c
join mdl_quiz_attempts a on a.userid = c.userid
join (select max(attempt) max_attempts from mdl_quiz_attempts group by userid) max on max.max_attempts = a.attempt
set c.timemodified = a.timemodified
where c.userid = :<USER_ID>

How to display designation details along with number of employees for each branch?

from hrm_personal_information(designation,branch) table how to get details of each designation (DESG_ID id, DESG_NAME) and each branch(BRANCH_ID,BRANCH_NAME) along with number of employees for each designation and each branch
Output is
SL. Designation Dhaka Barisal Jamalpur Naogaon
1 Directors 10 2 3 2
2 Doctor 5 6 5 8
3 Staff Nurse 3 5 6 8
4 Nurse 3 5 9 7
5 Auxiliary Nurse 6 7 8
6 Counselor 2 5 8 9
7 Call Center 9 9 6 4
8 Optometrist 6 0 3 5
9 Cook 6 1 2 6
Total 46 47 47 60
Grand Total 200

Finding continuous data from a table for months

I have a table which has month data in INT April=4, May=5 and so on. I want those records which have continuous data. My table is as follows. So if a record has discontinuous data, it should not be returned.
Continuous data means those records which having continuous four month. If records are there for 4,5,6,7 or 5,6,7,8 or 6,7,8,9 months then that record should come in result of a ID. If there records for a ID has 4,5,8,9 in month field this is discontinue data for me.
Initial query:
select ID, month from table1 where month in (4,5,6,7,8,9) group by month;
Initial Data:
PK ID month value
1 1 4 400
2 1 5 200
3 1 6 300
4 1 7 400
5 2 5 400
6 2 6 200
7 2 7 100
8 2 8 400
9 3 4 200
10 4 5 800
11 5 6 800
12 5 7 100
13 5 8 700
14 5 9 900
15 6 4 100
16 6 5 200
17 6 8 500
18 6 9 600
Result:
PK ID month value
1 1 4 400
2 1 5 200
3 1 6 300
4 1 7 400
5 2 5 400
6 2 6 200
7 2 7 100
8 2 8 400
11 5 6 800
12 5 7 100
13 5 8 700
14 5 9 900
My database is MySQL.
I have months from April(4) to Sept(9)
Try the below query this will work I hope!
SELECT ID, Month
FROM table1 WHERE month in (4,5,6,7,8,9)
GROUP BY ID, Month
HAVING count(ID)>3
kindly let me know this is working or not

Puzzle: find number in a given row and column in 2-dimensional array where no number may occur twice

We have a two-dimensional array with the number 0 in the upper left corner. The rest of the array is then filled with numbers so that each index contains the smallest positive integer possible that already exists neither on the same row or column.
Example:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 17 16
2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13 18 19
3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 19 18
4 5 6 7 0 1 2 3 12 13 14 15 8 9 10 11 20 21
5 4 7 6 1 0 3 2 13 12 15 14 9 8 11 10 21 20
6 7 4 5 2 3 0 1 14 15 12 13 10 11 8 9 22 23
7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22
8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 24 25
9 8 11 10 13 12 15 14 1 0 3 2 5 4 7 6 25 24
10 11 8 9 14 15 12 13 2 3 0 1 6 7 4 5 26 27
11 10 9 8 15 14 13 12 3 2 1 0 7 6 5 4 27 26
12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3 28 29
13 12 15 14 9 8 11 10 5 4 7 6 1 0 3 2 29 28
14 15 12 13 10 11 8 9 6 7 4 5 2 3 0 1 30 31
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 31 30
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 1
17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30 1 0
Given the row and the column in such array, I need to be able to find the number in the specified index in less than one second on a relatively new desktop PC (for row and column less than a million). My brute-force attempts so far have been so futile that it's clearly not the way I want to go with this. Presumably there must be a way to find out the number in question, in linear time (?), that doesn't require computing all the preceding numbers in the array.
Observation shows that the operator is the bitwise XOR (represent each operand as a binary number, XOR together the corresponding bits, read as binary).
Now on to prove it is the XOR:
Since the XOR with one argument fixed is a bijection on the other argument, the "that exists neither on the same row or column" is satisfied.
Now it just suffices to prove the "smallest" part, namely that any lower value already occurs if we reduce either operand:
foreach A >= 0, B >= 0, F >= 0:
(A xor B > F) => (exists D: D xor B = F) or (exists E: A xor E = F)
or equivalently
foreach 0 <= A, 0 <= B, 0 <= F < (A XOR B)
(exists D: D xor B = F) or (exists E: A xor E = F)
Note that we are no longer concerned about our operator, we're proving the minimality of XOR.
Define C = A xor B
if A = 0, B = 0, then minimality is satisfied.
Now, if A and B have the same magnitude (the same bit length), then clearing the top bit of both will not change C. Clearing the top bit is a translation towards the origin in the matrix, so if a smaller value exists above or to the left after translation, it is at the same relative position before the translation.
A and B must have a different magnitude to be a counter-example. XOR (as well as the operator under consideration) are symmetric, so assume A > B.
If F is of greater magnitude than A, then it's not smaller, and thus it's not a counter-example.
If F has the same magnitude as A, then clear the highest bit in A and in F. This is a translation in the table. It changes the values, but not their ordering, so if a smaller value exists above or to the left after translation, it is at the same relative position before the translation.
If F has a smaller magnitude than A, then, by the pigeonhole principle and the properties of XOR, there exists a D with a smaller magnitude than A such that D xor B = F.
summary: The proof that XOR satisfies the conditions imposed onto the solution follows from the symmetries of XOR, its magnitude-preserving properties and its bijection properties. We can find each smaller element than A xor B by reducing A, B and the challenge until they're all zero or of different magnitude (at which point we apply the pigeonhole principle to prove the challenge can be countered without actually countering it).

order group_by in codeigniter

i have a table
id typesignal close open cont
1 4 150 300 2
2 3 20 40 1
3 2 50 75 15
4 1 15.2 30.8 5
5 1 200 225 8
6 6 200 500 8
7 7 10 20 4
8 8 9 12 2
9 9 5 8 3
10 5 40 50 4
11 4 5 8 9
12 5 4 2 3
13 8 5 4 0
i want to display the last row of each kind from the typesignal column.
$this->db->group_by('typesignal');
$query = $this->db->get('signals');
but I need the last row that was create i use
$this->db->group_by('typesignal');
$this->db->order_by("idSignal");
$query = $this->db->get('signals');
but its not working.
The expected output is: 13,12,11,9,8,7,6,5,3,2
i use this query
$this->db->group_by('typeSignal');
$this->db->select_max('idSignal');
$this->db->order_by("idSignal", "DESC");
$query = $this->db->get('signals');
return $query->result_array();
is working the secret is $this->db->select_max('idSignal');
Thanx for the help