In HP QC SPS, i need to create a report with defect id, time the defect was in a particular status - sql

I have a task at hand, where i need to create a report with defect id, time the defect was in a particular status, In HP QC SPS.
The issue at hand is (for example) , if the status changed from 'new' to 'open in analysis', then to 'under investigation' and then changed it back to 'open in analysis'. the report should capture the time spend under each status. which means twice the status was 'open in analysis', so that time needs to be added and captured.
how can i achieve this.
can some one help me with a SQL query for the same?

I don't know what "HP QC SPS" means - should I? Does it understand Oracle SQL?
If it does: if your table has three columns, defect_id, ts (timestamp) and status, you need to compute the time in each status for each occurrence (even for the same defect_id) by using the lead() analytic function, partitioning by defect_id and ordering by ts; and then you need to group by defect_id and status and SUM(<these differences>).
If you want an illustration, I want one too. You provide input data, I show you how this works. While you are at it, please explain what happens with a status that is "current" (the last entry for a defect_id - unless the last status is resolved or closed).

Related

Keeping track of modifications in Power BI data

Let's say I have a list of the members of a team, and I keep track of their status (active/inactive, or present/absent, for instance). My file contains an id for each member, a column "updated at timestamp" as well as a column giving their current status. The list is updated daily, so some member's status can change from one day to the next.
What I would like to do is get the number of days the status was on "active/present" during a month (or a percentage of "active" during the month).
The problem being that the data is not stored : when there is an update, the column "status" changes but there is no history on whether it was on active/present or inactive/absent the previous day.
Could someone help me find a way to do that ?
Thanks in advance.
For the situation you mentioned, you can use a RDBMS systems. I am writing for SQL Server, probably you would use the "Temporal Table" for historical information.

Access Database - Most Recent Record - Max Function

I'm in the process of building a database to keep track of loaning equipment. I'm trying to build a query that will display the latest record of each machines location.
Relevant table is:
Movements:
Movement ID (PK)
EntryDate (Automatically generated on record entry)
Serial (FK from a table called stock, with (Make, Model etc)
Location (Where the machine is)
Status (Things like: Available, Testing, Sold etc)
Current query is:
SELECT Movements.Serial, Max(Movements.EntryDateMovements) AS MaxOfEntryDateMovements
FROM Movements
GROUP BY Movements.Serial;
Which spits out the latest date of a record, and the serial associated with it.
What I need is the status to be shown in the results, but it still be grouped by the serial.
My issue is that when I try and add that, it either comes back with an error with about the expression not being part of the aggregate function, or I get more results than expected, as it no longer just keeps the results unique to the serial.
I'm pretty new Access, and have so far been able to muddle through guides, and books, and this site, to get everything else working, but i'm stuck at this hurdle.
Any help would be much appreciated.
Select top 1 *
from Movements
order by EntryDateMovements desc
This will give you everything for the newest record. This is TSQL but I think it carries over to Access.
Try this
Select t.serial,t.EntryDateMovements ,t.location, t.status
From movements as t
Inner join (SELECT Movements.Serial, Max(Movements.EntryDateMovements) AS MaxOfEntryDateMovements
FROM Movements
GROUP BY Movements.Serial) as MaxMovements on t.serial= MaxMovements.serial and t.EntryDateMovements=MaxMovements.MaxOfEntryDateMovements

How to model process and status history in a data warehouse?

Let's say that we have D_PROCESS, D_WORKER and D_STATUS as dimensions, and the fact F_EVENT that links a process (what) with a worker (who's in charge) and the "current" status.
The process status changes over time. Shoud we store in F_EVENT one line per process/status/worker, or one line per process/worker, and "somewhere else" one line per status change for a given process/worker?
I'm new to Datawarehouse and it's hard to find best practices/tutorial related to data modelization.
Read The Data Warehouse Toolkit by Ralph Kimball for a good introduction to dimensional modeling.
It sounds like you are storing a process change event in F_EVENT. If this process has a defined beginning and end, I would build a snapshot fact table which would let you track the process over time (simply updating the row each time the process moves from one step to another).
EDIT:
I'll try to make a general case using your dimensions as examples.
For D_PROCESS, modeling a "process" isn't usually modeled as a dimension, and you called it a "what", so I'm going to rename this to "D_ACCOUNT".
The basic data model will be for a "tax processing system" in which WORKERS are processing ACCOUNTS, and each ACCOUNT/WORKER combination has several possible "STATUSES" of where this process currently stands.
D_ACCOUNT
ACCOUNT_NUMBER
ACCOUNT_TYPE
D_WORKER
WORKER_ID
FIRST_NAME
LAST_NAME
BADGE_NUMBER
SHIFT
D_STATUS
STATUS_ID
STATUS_NAME
Now if I want to report on all "events" that have happened to an Account, performed by a worker, I can build a Transaction-level fact table F_EVENT:
F_EVENT
ACCOUNT_ID
WORKER_ID
STATUS_ID
EVENT_TIME_ID
Metrics taken at time of the measurement (Cost, Worker time spent, etc)
We call the unique combination of dimensions that identifies a row the Granularity or Grain of the fact table.
The grain of this table is Account, Worker, Status, and Time. It answer questions like "How much time did my workers on shift 3 spend processing accounts on Wednesday?" or "How many events occured that changed the processing status to "CLOSED"?
I'm not sure how much this type of table would help.
Instead, say you are interested in tracking the process itself as it moves through various statuses. I'm going to assume that the status always moves forward in time, from "NOT STARTED" to "IN PROCESS" to "CLOSED".
I'll build what Kimball calls an "Accumulating Snapshot Fact table.
F_TAXPROCESSING
ACCOUNT_ID
WORKER_ID
CURRENT_STATUS_ID
NOT_STARTED_DTTM
NOT_STARTED_FLAG
IN_PROCESS_DTTM
IN_PROCESS_FLAG
CLOSED_DTTM
CLOSED_FLAG
This table's grain is Account, Worker. This table keeps track of the "process" by updating the date/time of the change to the status, and a flag when that status has been reached.
This allows you to track the process over time, allowing you to see how many accounts have reacted the "IN PROCESS" status, how long it took to get there, et cetera.

Recurring Orders

Hi everyone I'm working on a school project, and for my project I chose to create an ecommerce system that can process recurring orders. This is for my final project, I'll be graduating in May with an associates in computer science.
Keep in mind this is no where a final solution and it's basically a jumping off point for this database design.
A little background on the business processes.
- Customer will order a product, and will specify during checkout whether it is a one time order or a weekly/monthly order.
- Customer will specify a location in which to pick up their order (this location is specific only to the order)
- If the value of the order > 25.00 then it is accepted otherwise it is rejected.
- This will populate the orders_test and order_products_test tables respectively
Person on the back end will have a report generated for deliveries for the day based on these two tables.
They will be able to print it off and it will generate a list of what items go to what location.
Based on the following criteria.
date_of_next_scheduled_delivery = current date
remaining_deliveries > 0
Once they are satisfied with the delivery list they will press "Process Deliveries" button.
This will adjust the order_products_test table as follows
Subtract 1 from remaining_deliveries
Insert current date into date_of_last_delivery_processed
Based on delivery_frequency (i.e. once, weekly, monthly) it will change the date_of_next_scheduled_delivery
status values in the order_products_test table can either be active, hold, or canceled, expired
I just would like some opinions if I am approaching this correctly or if I should scratch this approach and start over again.
A few thoughts, though not necessarily complete (there's a lot to your question, but hopefully these points help):
I don't think you need to keep track of remaining deliveries. You only have 2 options - a one time order, or a recurring order. In both cases, there's no sense in calculating remaining deliveries. It's never leveraged.
In terms of tracking the next delivery date, you can just keep track of the day of the order. If it's recurring -- monthly or weekly, regardless -- everything is calculable from that first date. Most DB systems (MySQL, SQL Server, Oracle, etc) support more than enough date computation flexibility so that you can calculate this on the fly, as opposed to maintaining such a known schedule.
If the delivery location is only specific to the order, I see no use in creating a separate table for it -- it's functionally dependent on the order, you should keep it in the same table as the order. For most e-commerce systems, this is not the case because they tend to associate a list of delivery locations with accounts, which they prompt you about when you order more than once (e.g., Amazon).
Given the above, I bet you can just get away with 2 of your 4 tables above -- Account and Order. But again, if delivery locations are associated with Accounts, I would indeed break that out. (but your question above doesn't suggest that)
Do not name your tables with a "_test" suffix -- it's confusing.

has anybody the trac report to get all tickets without milestone?

i'm looking for the TracQuery for the trac report to get all tickets without assigned milestone listed. have you already composed this query, if yes, would you share it? thx in advance.
Something like this should do it, adapt to suit your precise needs....
SELECT
id AS ticket,
datetime(time,'unixepoch'),
summary,
status,
priority,
description AS _description
FROM ticket t
WHERE t.milestone is NULL AND t.status<>'closed'
ORDER BY time desc, status, severity, summary
The key part for you is simply to filter on the milestone being NULL.
I could reproduce the 'No matches found' for the answer by Paul Dixon, so I tried it on my own:
SELECT
id AS ticket,
time AS date,
summary,
status,
priority,
description AS _description
FROM ticket t
WHERE t.milestone not in (
SELECT name
FROM milestone
)
AND t.status<>'closed'
ORDER BY time desc, status, severity, summary
Note: Trac has some "magic" result table column names. Assigning 'date' will do the appropriate conversation of time stamp integer to date string automagically - even better - respecting the current internal Trac time stamp format of POSIX micro-seconds (since Trac 0.12) too. In this respect the SQL statement above is even the most portable solution I'm aware of.
This is quite simple using Trac's query language instead of raw SQL. On a wiki page, you can use query:milestone= to create a link to a query of all tickets without a milestone assigned. Invoke the macro [[TicketQuery(milestone=)]] to insert the list of matching tickets into the wiki page.
To do the same thing on the "Custom Query" page, remove all search criteria and add a single criteria of "milestone" "is" and leave the third field blank.