I need to get the results grouped by company for every year.
I tried below query :
http://localhost:8080/solr/select?q=&fq=status_created_at:[2011-12-31T4:00:00Z TO 2016-04-13T4:00:00Z] AND -company:(20 26 27 536)&facet=true&facet.field=company&facet.date=status_created_at&facet.date.start=2012-01-01T4:00:00Z&facet.date.end=2016-4-12T4:00:00Z&facet.date.gap=+1MONTH&fl=id&wt=json&rows=0&start=0&defType=dismax&qf=text
I expect the result to return like this
{ 2015: {"1":123, "2":412}, 2014: {"1":123, "2":412}, }
But the query does not give expected results. I understand my requirement is combination Grouping+Faceting but do not know how to fine tune the query.
Help me to solve this.
Related
I am unable to sum phone call times that are being stored in a SQL fact table
I have a SQL table of phone call times, by person, which are being used in a Cognos Analytics Data Module.
I would like to use this data in a crosstab and report a total call time in HH:MM:SS for each person.
SQL column is formatted time(0) when I try to Total the time, Cognos throws a [MSR-VRF-1202 The column "Call Length" has the data type "time" and can't be aggregated] error.
What is the correct way to display a total of Call Times.
UPDATE
I have managed to overcome half the problem by using a number of query calculations in Cognos Anaytics.
I updated the SQL fact table to include a new measure of time in seconds then used the query items below.
HH as FLOOR(TOTAL([CALLTIMEINSECONDS])/3600)
MM as FLOOR(([CALLTIMEINSECONDS]-[HH]*3600)/60)
SS as [CALLTIMEINSECONDS]-([HH]*3600)-([MM]*60)
HH1 as IF ([HH]<10) THEN ('0'+CAST([HH],VARCHAR(4))) ELSE (CAST([HH],VARCHAR(4)))
MM1 as IF (MM<10) THEN ('0'+CAST(MM,VARCHAR(2))) ELSE (CAST(MM,VARCHAR(2)))
SS1 as IF (SS<10) THEN ('0'+CAST(SS,VARCHAR(2))) ELSE (CAST(SS,VARCHAR(2)))
ALL TIME as [HH1]+':'+[MM1]+':'+[SS1]
This works in individual Crosstabs rows however will not summarise and also does not work on any charts.
Why would two individuals take the time to read and vote a genuine request for assistance down? I thought this was a place to share knowledge and experience. Clearly these people need to get out more, a life, or get laid. Sorry I can’t help but hopefully someone else will 😉
I'll assume
you would use the terms time and duration synonymously.
you are using MS SQL Server.
Adjust your final solution accordingly.
My solution in SQL is:
format(sum(DATEDIFF(second, TIMEFROMPARTS(0,0,0,0,0), [CallDuration])) / 3600, '0#') + ':' +
format(sum(DATEDIFF(second, TIMEFROMPARTS(0,0,0,0,0), [CallDuration])) / 60, '0#') + ':' +
format(sum(DATEDIFF(second, TIMEFROMPARTS(0,0,0,0,0), [CallDuratoin])) % 60, '0#')
A Cognos-based solution may involve multiple queries. Here are the basic pieces:
Convert the times to numbers.
Sum the numbers.
Convert the summed numbers to times (or time parts -- hours, minutes, seconds).
Format the output.
If you calculate the parts separately, the formatting can be done on the page rather than the query Cognos as 5 text items, some with a Source type of Text and some with a Source type of Report Expression or Data item value. In other words, 3 query calculations and 2 text items.
<hours>:<minutes>:<seconds>
I have two particular days in DB and I want to calculate the difference in hours of this two days.This is the sample; stardate = 01.06.2018 02:00:51 and
finisdate = 01.06.2018 03:37:00 and in MSSQL I used this query
CAST( ROUND(CAST(BitisTarihi-BaslangicTarihi as float)*24,5,0) as numeric(18,5))
Mssql give me this result : 1,60250 but When I use excel to calculate the difference ı get this result : 1,60248 .
Why ı get different results.This important for me because I get mssql query result by excel.When someone checks the result they see the difference,
Is it possible that you're doing the round in Excel before multiplying by 24?
This gives me 1.6025
=(A1-B1)*24
This gives me 1.60248
=ROUND(A1-B1,5)*24
" to calculate the difference in hours of this two days" <-- if you really just need to extract the hours from excel, the use of hour() and date() will be sufficient. (:
Software: MS Excel 2016
Here is a table
Given, there will alway be same number of triggers for a particular ID. But I don't want to count those triggers multiple times.
I tried the following DAX. My expected answer is 72, but I get 143 instead. How to fix?
Distinct_Matches:=CALCULATE(sum(Incidents[Triggers]),DISTINCT(Incidents[Incident_ID]))
Use this:
=SUMPRODUCT(B2:B7/COUNTIF(A2:A7,A2:A7))
Here is the formula with structured references:
=SUMPRODUCT(Incidents[Triggers]/COUNTIFS(Incidents[Incident_ID],Incidents[Incident_ID]))
The below would work, assuming that Incident_ID's trigger value is the same across the ID Number.
Measure 1:=SUMX( DISTINCT(Table1[Incident_ID]), CALCULATE(AVERAGE(Table1[Triggers])))
Table1 just being the name I used as part of the quick test.
The idea being that the sumx would iterate though every unique Incident_ID and sum the result of the calculate statement. The calculate statement is using average, since it will return the unique value. E.g. Average(41+41) = 41. You could also use MIN or MAX as well.
I need to get the last 10 days orders from 3cart rest API using nodejs. I read the API document but I couldn't figure out how to get the last 10 days orders.
Please give me your suggestions/ideas.
Thanks in advance!
It looks like this is the API call you want, however it does't have a sort or orderby parameter, which means you won't be able to get the last 10 orders.
http://apirest.3dcart.com/Help/Api/GET-3dCartWebAPI-v1-Orders-orderid_invoicenumber_orderstatus_datestart_dateend_limit_offset_countonly_lastupdatestart_lastupdateend
However it does have a count feature, which means there is a way to get the last 10 orders by doing a count of all the rows in the db and skipping them all -10.
example
it counts the orders
[-------------------------] // <-- = 25
the second call we skip the first 15 results and set the limit to 10.
[---------------==========] // <-- we take the last 10 orders
so we want to add the params limit=10,offset=15. The way you offset the results is by doing 25 - 10 or totalCount - 10.
in google search box when we type something like " 'java code' + inurl:javalobby " we will get the search results where the website link contains the string javalobby and the page will contain the string java code.
Similarly is there a way to search the latest updated content in the internet which will contain the keyword entered in the search box ?
Thanks.
There are two tricks in google to narrow your search based on date. It is using either the keyword daterange:startdate-enddate or by content creation date.
1. Using the syntax daterange:startdate-enddate : The catch is that the date must be expressed as a Julian date, a continuous count of days since noon UTC on January 1, 4713 BC. So, for example, July 8, 2002 is Julian date 2452463.5 and May 22, 1968 is 2439998.5. Furthermore, Google isn't fond of decimals in its daterange: queries; use only integers: 2452463 or 2452464. You can convert Julian dates online here.
Example:- Geri Halliwell left the Spice Girls around May 27, 1998. If you wanted to get a lot of information about the breakup, you could try doing a date search in a ten-day window—Say, May 25 to June 4. That query would look like this:
"Geri Halliwell" "Spice Girls" daterange:2450958-2450968
2. Searching by content creation date : Try adding a string of common date formats to your query. If you wanted something from May 2003, for example, you could try appending:
("May * 2003" | "May 2003" | 05/03 | 05/*/03)
A query like that uses up most of your ten-query limit, however, so it's best to be judicious— perhaps by cycling through these formats one a time. If any one of these is giving you too many results, try restricting your search to the title tag of the page.
If you're feeling really lucky you can search for a full date, like May 9, 2003. Your decision then is if you want to search for the date in the format above or as one of many variations: 9 May 2003, 9/5/2003, 9 May 03, and so forth. Exact-date searching will severely limit your results and shouldn't be used except as a last-ditch option.
When using date-range searching, you'll have to be flexible in your thinking, more general in your search than you otherwise would be (because the date-range search will narrow your results down a lot), and persistent in your queries because different dates and date ranges will yield very different results. But you'll be rewarded with smaller result sets that are focused on very specific events and topics.