Filter TOP query so that a result cannot be in the top if the column value is already present in a previous row
Hi,
Any help would be appreciated. I have a query that is the top(5) but I want them to be distinct on only one column value, not on the entire row. Any help would be really appreciated.
Regards,
Seamus
SELECT TOP 5 [DISTINCT COLUMN], MAX([SOME OTHER COLUMN]), MAX([SOME OTHER COLUMN], MAX([SOME OTHER COLUMN])
FROM [TABLE]
GROUP BY [DISTINCT COLUMN]
This will do it, but the values may display incorrectly, since it's taking the MAX value of each partition of your distinct column, so another way would be:
;WITH CTE AS(
SELECT *, ROW_NUMBER() OVER(PARTITION BY [DISTINCT COLUMN] ORDER BY NEWID()) AS RN
FROM [TABLE])
SELECT TOP 5 [DISTINCT COLUMN], [OTHER COLUMN], [OTHER COLUMN]
FROM CTE
WHERE RN = 1
Thanks.
Similar Messages
-
Cannot create a calendar collection because there are too many already present in
My OS X Server (Yosemite) error log is throwing this error:
2014-10-22 00:03:07+0800 [-] [caldav-2] [-] [twistedcaldav.storebridge.CalendarCollectionResource#error] Cannot create a calendar collection because there are too many already present in <twistedcaldav.directory.calendar.DirectoryCalendarHomeResource object at 0x10743a750>
...when I attempt to add more than 50 lists in the Reminders app. I had a similar issue in Mavericks. Is this "50" number available to modify in a config file somewhere?
My plan is to manage GTD-type projects in my Reminders apps (on iOS and OS X), but this limit is keeping me from creating a list for EVERY project I have.Woohoo! I set the integer to "500" and I now have over 200 lists added, and syncing, to my Reminders app and related tools.
Here's exactly what I did after reading the response from Linc Davis:
Stop the Calendar service
Create /Library/Server/Calendar and Contacts/Config/caldav-user.plist
Edit contents of "caldav-user.plist", setting your desired integer value:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MaxCollectionsPerHome</key>
<integer>500</integer>
</dict>
</plist>
4. Start the Calendar service
Enjoy your many more lists.
Note that a file created in a place other than ~/ may have permissioning issues. To get around this, I made a copy of /Library/Server/Calendar and Contacts/caldavd-system.plist, then renamed and edited that file with nano in terminal. -
Query not retrieving exact results.
I have a query which shows different result from what i have it in the cube.
I have a document number in rows and two key figures one amount and another which shows no. of days for clearance. In the cube, for the same selection criteria , it gives me three records for the same document no. but in query its is gving me one record with different values in KF.
sample.
In cube
Doc Amount No. Days for CLearance
59 100 31
59 400 14
59 500 38
In query the result shows as
59 1000 1
Any Ideas where it is doing wrong. No of days for clearance is calculated from the difference btw posting date and clearing date. I need No. of Days to further develop this query.Is it something to do with compression, or query cache..
Any Ideas!!1
Thanks in Advance..
VeeruSorry, the Result I've shown may be little confusion .. Here is the clear picture..
In query..
DOC -
Amount -
No.of Days to CLearing
59 -
1000 -
1
In Cube
DOC -
Amount -
No.of Days to CLearing
59 -
100----
31
59 -
500-------14
59--400-----18
the value of Days to Clearing is showing as 1.
Properties of that key figure are defined as follows..
KF as NUMBER
Aggregation :Summation
Exp.Aggregation : Counter All Values.
Ref Characteristic : cal day.
Is this something related to the display properties in BEX. Again, In cube the records are correct..
Thanks
Veeru -
DB buffer cache vs. SQL query & PL/SQL function result cache
Hi all,
Started preparing for OCA cert. just myself using McGraw Hill's exam guide. Have a question about memory structures.
Actually, DB buffer cache is used to copy e.g. SELECT queries result data blocks, that can be reused by another session (server process).
There is also additional otion - SQL query & PL/SQL function result cache (from 11g), where also stored the results of such queries.
Do they do the same thing or nevertheless there is some difference, different purpose?
thanks in advance...There is also additional otion - SQL query & PL/SQL function result cache (from 11g), where also stored the results of such queries.Result cache located in shared pool.So it is one component of shared pool.When server process execute query(and if you configured result cache) then result will store in shared pool.Then next execution time run time mechanism will detect and consider using result cache without executing this query(if data was not changed this is happen detection time)
Do they do the same thing or nevertheless there is some difference, different purpose?.Buffer cache and result cache are different things and purpose also,but result cache introduced to improve response time of query in 11g(but such mechanism also implemented in 10g subquery execution,in complex query).In buffer cache holds data blocks but not such results.
Edited by: Chinar on Nov 4, 2011 4:40 AM
(Removing lots of "But" word from sentences :-) ) -
Using external parameters within MS Query returning that data right into a pivot table Excel 2010
In Excel 2010 i was able to use the external parameters within MS Query returning that data right into a pivot table. But the parameter on the worksheet will not save in the paremeter setting of the data connection. And if you save it and open
it and try to refresh the pivot table Excel stops responding and you have to force the file closed. I found out the reason to crash is that it did not keep the parameter saved.
Can this be fixed?Hi,
Just
checking in to see if the information of Oskar was helpful. Please
let us know if you would like further assistance.
Jaynet Zhang
TechNet Community Support -
Content Search Query Builder - filtering for custom column value
I want to use a CSWP to display certain pages in a slideshow format on a site. However, to filter them in a preferred manner, the pages library has a custom column "Spotlight" which is a Boolean type (e.g. yes/no).
In my "Build Your Query" configuration page, I have added a keyword filter "SpotlightOWSBOOL=Yes" as the criteria to display my results. This is not working, despite the fact that I currently have pages flagged as "Spotlight"
in this library.
My question is - how can I achieve this result of displaying only pages with a custom column value "Spotlight" as "Yes"?Hi Owen,
Could you capture a screenshot about your Crawled Property for your list column "Spotlight"? Is it name "SpotlightOWSBOOL"?
If your library column name is "Spotlight", you can create a custom
Manged Property (e.g. create name as SpotlightMangedProperty)to map the
Crawled Propery (e.g. may ows_spotlight, or ows_SpotlightOWSBOOL?) genegrated by list column "Spotlight", then start a full crawl.
Then you can add the keyword filter like below in "Build Your Query" dialog of CSWP web part, then check if the correct items are filtered.
SpotlightMangedProperty:"yes"
If the above value "yes" doesn't work, please also try
SpotlightMangedProperty:"True", or try SpotlightMangedProperty:1
More information about this topic you can read is below.
https://technet.microsoft.com/en-us/library/jj219667.aspx#proc2
https://msdn.microsoft.com/en-us/library/office/ee558911.aspx#kql_property_restriction_queries
Thanks
Daniel Yang
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
How to have total result of CKF use the formula of the CKF
Hello experts, in a couple of BI reports we need that a Calculated Key Figure's total result use its same formula, instead of using the different calculations that are offered for totals. Let me explain:
We have the following report (please ignore the "-"):
Month----Entries---Exits----Percentage
Jan--82--
25%
Feb--63--
50%
Mar--81--
12.5%
Result--226--
Percentage is calculated as "Exits / Entries * 100", or "Exits %A Entries" (in the latter case, the default calculation of total is "average", while in the former it is "sum") and has an exception aggregation of "Average" with reference characteristic "Calendar Month". The problem we have run up with is that we want the result of Percentage calculated the same way, which is somewhat similar to an average. However, the result is always calculated based on the individual results. This gives us different numbers.
Result Percentage = Total Exits %A Total Entries = (6 / 22) * 100 = 27.27% (CORRECT)
Result Percentage = Average of individual Percentages = (25 + 50 + 12.5) / 3 = 29.16% (INCORRECT)
I've tried different approaches, such as changing the reference characteristic and exception aggregation, selecting "average" as the method of calculating results or individual values, checking the "cummulated" and "Also apply to results" checkboxes, etc. but I was unsuccessful.
Any thoughts?I'll post sample data and give a more thorough explanation of both queries (the one that works correctly and the one that does not). Both queries come from the same infocube:
The correct query: it is a monthly report of entries vs exits for all store types but one (called "general" which should not be included here) in a base country (so if base country is, for example, France, then all stores in France). The query structure and sample data (ignore the "-"):
January--February--
Exits--EntriesPercentageExitsEntries--
Percentage
Store type 1--52025%918--
50%
Store type 2--41822.22%320--
15%
Store type 3--125621.43%1360--
21.67%
Total--2194
22.34% -2598--
25.51%
This query is initially restricted by the base country and the store type "general" (so that it is not considered).
The incorrect query: it is a monthly report of entries vs exits for store type "general" ONLY, outside the base country. The query structure and sample data (for ease of analyzing, I am repeating the data in the key figures, changing the store for the calendar month):
Country 1--Country 2--
Exits--EntriesPercentageExitsEntries--
Percentage
January--52025%918--
50%
February--41822.22%320--
15%
March--125621.43%1360--
21.67%
Total--2194
30.33% -2598--
28.89%
This query is initially filtered by the store type "general" and the base country (so that it is not considered).
As you can see, the percentage can change quite a lot. What confuses me is that in both cases I am using the same CKF "Percentage" with "Average" as exception aggregation and "Calendar Month" as Reference Characteristic.
Percentage = Exits %A Entries
When dealing with individual results, everything is ok. It is only when dealing with totals that the query miscalculates, calculating the totals as the "Percentage" average (the sum of individual values / the number of values).
I modified the incorrect query to match the correct query, so that it looked like a copy of it, and the results were calculated correctly. Then, when I modified it again to return it to its original form, the results were calculated incorrectly again.
Any suggestions? Do you think this could be a configuration issue or something like that? -
Performance issue: View query is calculating a column value before filterin
Hi,
I have a view like this.(My view is more complex than this..I just tried to imitate the situation )
Select emp_id, emp_name, calculate_salary(emp_id) salary
From employees
Where nvl(department, '@@##$$') = nvl(get_global.department, '@@##$$')When I execute the below query
select emp_name from my_view where salary=10000 by setting a value to get_globals.department I found that it first calls the calculate_salary instead of applying the filter for departments. By somehow the cost base analyzer thinks that calling the function is cheaper than applying the filter. I wonder whether there is way to direct the cba and say to first apply the filters before calculating column values.
Any suggestions ?
ThanksI don't think it's possible.
Before a WHERE clause can be applied the data has to be collected for the row so Oracle, I would imagine, isn't going to differentiate between what is a database column and a function, fetch just the columns, do the filtering and then go back to calculate the rest of the columns; it's just going to get all the columns, including the calculated ones, and then apply the filters.
The only option would be to do...
select emp_id, emp_name, calculate_salary(emp_id) salary
from (select emp_id, emp_name
from employees
where nvl(deparment, '@@##$$') = nvl(get_global.department, '@@##$$')
)as your view -
Hi,
I just bought a new Macbook Pro 15" with SSD 256 Gb and its almost a brand-new (the 4th time to use the device) a while ago i was trying to connect to my home wireless network it said that the connection is timed out so i clicked the airport sign on the top it said that your airport is not configured then I restarted the system but it didn't restarted it showed the grey screen with the apple logo and the spinning wheel for more than 10min so I tried the force shutdown by pressing the power button till it switched off I waited for 5min then pressed the power button to start or boot the system and again the grey screen with the apple logo and the spinning wheel, I waited for more than 20min nothing changed, any solution please?
Your help is really appreciated"Thanks a lot i followed the instructions for safe mode (i found out that i was pressing the C button after restarting) i did whats written there but the repair couldn't be performed so in addition i needed to re-formate the HD so i erased the volume and then repaired the disk--> quite disk utilities --> start the installation from the installation DVD.
Thanks really appreciating your help -
How to Control the width of the Filter row in Table View
Hi !
I have a Table View with filter='application'. The filter works fine but I am not able to control the width of the columns of the tableview .
On filtering, if there are not items in the table view the columns shrink to the minum width....and it looks very odd.
Can you help me how to control the width of the Filter-Row in Table Veiw.
Thanks and Best Regards,
BindiyaHi Raja,
"FIXEDCOLUMN" did not help in the width of the column, but it just showed all the rows merged in the column.
I have a cloumn called "COUNTRY" and its width is set to "20". The Filter of the column "COUNTRY" is a dropdownlist whos value is update with new values.
On filtering if there is any row visible then the column width is adjusted to the maxmimum length of the dropdownlist ( this is because of the "EDIT" attribute in column definition ). But if there is no rows visiblel for the selected filter value then the filter row shrinks to the width = "20" and the dropdownlist is not visible completely.
Need to know how to control the width of the FILTER column.
Thanks and Best Regards,
Bindiya -
Displaying the result of the TOP N query
Hi all,
we are facing a challenging task were we are going to build a query that gives the answer on the question:
How many different materials (of the top sold) represent 80% of the total sales in quantity?
The result should of the query should be very short:
2002 2003 2004
Nr of materials
reps 80% 432 453 499
The query is build on a CO-PA based cube, where each line corresponds to a billing item with material and quantity.
By using a Top 80% condition on the quantity sold keyfigure we get out the top 80% materials sold:
Year Material QTYSold QTYSold-Ranked
2002 Mtr0323 10000 1
Mtr0262 9000 2
Mtr0243 8700 3
Mtr0763 600 423
Result 932000 423
2003 Mtr0123 9700 1
Mtr0332 9100 2
Mtr0243 8700 3
Mtr0763 543 453
Result 912000 453
We would like to supress the materials and only show the result row (or the raked position of the last material).
The problem is that the 'Calculate Single Value As' properties of a formula (or keyfigure) only applies on Displayed Data values. All tests we have done so far with 'supression of zeros' & 'always hide' has messed up or counting / ranking functions.
Is there any function in within formulas that have same functionality like Count,Rank etc?
Is there any other way to supress materials and only show results?
Any suggestions are welcome!Irina,
Should be achievable using exception aggregation and pre-query.
Create a query that gives the list of material that account for 80% of the sales using condition on the sales column.
In the second query, using exception aggregation, count the number of materials that make up this set for the year. Create a new calculated key figure with the formula as qual to sales key figure. In the properties window, press the enhance button and select count of all values in the first drop down and material in the second drop down. Filter the query on material with a characteristic variable with processing as replacement path. In the variable point it to the first query. Drilldown for this will be year.
This will give you number of materials for one year. If you want comparitive for three years, then three pre-queries and three variables with the calculated key figure restricted to a variable pointing to one years query.
You can use pre-calculated value sets to improve the run for the result query.
Cheers
Aneesh -
I click on a new tab, then do a google search in the bar at the top of the page. Results come up in a different tab that I didn't want to disrupt. Erg! Mac OS
To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
If you see a warning then you can confirm that you want to access the about:config page.<br />
*Use the Filter bar at the top of the about:config page to locate a preference more easily.
*Preferences that have been modified show as bold (user set).
*Preferences can be reset to the default via the right-click context menu if they are user set
*Preferences can be changed via the right-click context menu: Modify (String or Integer) or Toggle (Boolean) or by double-clicking the line with the pref
See also:
*http://kb.mozillazine.org/about:config -
Filter in query result table not populated by criteria previously selected.
Hi Experts,
I'm currently working on the the Upgrade of our BW production line from
release 3.0b to 7.0:
Configuration of target system
BW system : Release 7.0
BEx Analyser : Release 2004s, Support Package9, Patch 1, Revision 321
Sap Gui 6.4
We're especially trying to check the non-regression of the non-converted queries in the new system (release 7.0).
And we get the following issue: After having selected the selection criteria in the selection window, the reminder of selected criteria is not done in the filter part of the target query result. Is it a normal behavior or not ?
Indeed, in the previous system configuration (BW 3.0b), the user is accustomed to seeing just above his result table the selection criteria that he had previously filled in in the selection window.
Please find herewith an example describing the problem.
Thanks in advance for your help.In order to be more clear, hereunder an example:
- I have a field untitled "Business Division"in the selection window.*
- I fill in this field with the value "OND"
- I execute the query with this value for this field.
- The query result correclty appears.
- I click on the "Filter" button to display the Filter table with the columns "Navigation pane" and "Filter criteria".
- In the "Navigation pane", there is the field "Business Division".
- For me, the corresponding "Filter criteria" should be the value "OND", but nothing is displayed...
Thanks in advance foryour help.
Regards,
Steph -
In iTunes on my windows 7 PC, in the Edit/Preferences dropdown window,some of the tab windows are not large enough to see all options that are available. The borders of the window cannot be draged larger. As a result, I can not uncheck or check some box's on several of the preferences pages. The Apple people at the store did not help. I have lownloaded the latest version of iTunes and this is still an issue. HELP.
Is there really nobody else with this problem? Really?
-
I accidentally installed a toolbar i do not want. i think i successfully uninstalled it, but after it was installed, when i go into the facebook app, there is a strip across the top of the facebook page on which i cannot click on to . this strip includes my spot on which i click on to my wall or homepage in facebook. if i move the page down far enough, i can click on other things, but never can i get far enough down to click on these tabs. this only happens in firefox, which i prefer wayyy over google chrome for gaming. do i need to delete firefox and reinstall? please help!
Recently, the Yahoo Toolbar and the Babylon extension have been reported to cause that problem. They seem to overlap invisibly over the top of the web page display. If you have either or both, uninstall or disable them/it, or see if an update is available that solves the problem.
*See --> http://support.mozilla.com/en-US/kb/Uninstalling+add-ons
*See --> http://support.mozilla.com/en-US/kb/Cannot%20uninstall%20an%20add-on
*See --> http://kb.mozillazine.org/Uninstalling_toolbars
If that does not solve the problem:
*See --> [http://support.mozilla.org/en-US/kb/Troubleshooting+extensions+and+themes Troubleshooting extensions and themes]
*See --> [http://support.mozilla.org/en-US/kb/Troubleshooting+plugins Troubleshooting plugins]
*See --> [http://support.mozilla.org/en-US/kb/Basic+Troubleshooting Basic Troubleshooting]
'''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
Not related to your question, but...
You may need to update some plug-ins. Check your plug-ins and update as necessary:
*Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
*'''''Adobe Shockwave for Director Netscape plug-in''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
*'''''Adobe PDF Plug-In For Firefox and Netscape''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
*Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
*'''''Next Generation Java Plug-in for Mozilla browsers''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]
Maybe you are looking for
-
Cannot see my XP machine in Finder when linked thru Time Capsule
I migrated from a Netgear Range Max to a 500g Time Capsule to make backups "easy". The backups from my MacBook seem to be going o.k. I had no trouble seeing all networked local machines before the change. Have two PCs wired with ethernet cables thru
-
Outlook Express 4.5 "End of file reached." "Compress Mailbox" is greyed.
I am trying to get my friend's stuff off his Blueberry iMac, which was using OS 8.6, and onto his new Intel iMac. He's got OE 4.5 on the Blueberry. I don't know what he did to it (he told me weeks ago, but I've forgotten), but suddenly, all messages
-
How to upgrade to lion os x 10.7
I am running 10.6.8 and wish to eventually upgrade to 10.7.4. Where do find the upgrade for downloading?
-
on Jdeveloper 11g Release 2. I got an af:autoSuggestBehavior working in this way : Accountid is the field with the autoSuggest type: 1 show 1000 1010 1020 1030 I want this Type : 1 show 1000 Petty Cash 1010 Cash on Hand 1020 Regular Checking 1030 Sav
-
Exception when run the link for exchangeProfile.
Hi all: It is found that exchangeProfile service is not installed or not deployed on NW at least, when I check through visual admin. exchangeProfile, IntegrationServices, ExchangeDirectory, ExchangeRepository are not deployed services,