Max(count(*))
countries(country_name, country_id, region_id)
Employees(employee_id,first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_PCT, manager_id, department_id)
departments(department_id, location_id, manager_id, department_name)
job_history(employee_id, start_date, end_date, job_id, department_id)
jobs(job_id, job_title, min_salary, max_salary)
locations(location_id, street_address, postal_code, city, state_province, country_id)
regions(region_id, region_name)
question is display all countries that are located in the region which has most countries in the countries table
select country_name
from countries
where region_id=1
--(select max(count(*)) from countries group by region_id)Instead of using 1 where where clause, i need to write a sub query to get the region 1.
Oficially tested ;) :
SQL> insert into countries values('France',1,1);
1 row created.
SQL> insert into countries values('Italy',2,1);
1 row created.
SQL> insert into countries values('China',3,2);
1 row created.
SQL> insert into countries values('India',4,2);
1 row created.
SQL> insert into countries values('Mongolia',5,2);
1 row created.
SQL> select country_name,
2 country_id,
3 region_id
4 from countries
5 where (region_id,1) in (
6 select region_id,
7 dense_rank() over(order by count(*) desc) rnk
8 from countries
9 group by region_id
10 )
11 /
COUNTRY_NAME COUNTRY_ID REGION_ID
China 3 2
India 4 2
Mongolia 5 2
SQL> SY.
Similar Messages
-
What is the max. count of internal worker-threads in B1iSN 88?
Hi Experts,
We have an installation of B1iSN 88 with an ECC 6.0 and 54 SAP Business One installation. The Hardware is 8 Core multi-threads processor. 32GB Memory. Now we have a problem with the queuing of Events. What we have found is that the configuration of the internal worker-threads is set to -1(please see below for the settings). We change the settings to xcl.threads=20 and it improves the queuing. My question is what is the max. count of internal worker-threads per core? so that we can know how many worker will set and if we need to upgrade the CPU to 16 Core..
# The max. count of internal worker-threads afforded for the internal Scheduler (defaults to 1)
# The value of 0 means that there is no limit (what in general should not be set up).
# A negative value means the count of threads per available processor
xcl.threads=-1
Regards,
WilsonYou're very welcome.
Yes, they are very nice machines.
What a jump in performance when I swapped out the Pentium 4 620 mine had, for the PD 945, and tossed in 4 GB of memory.
That box will also run the Radeon HD 6570 with no problem too, which is what I put in mine.
The downside of that model is that there are no settings for ahci or raid.
I own or have owned every CMT since the d510 with the exception of the dc7900.
My main PC is now the 8200 Elite CMT which I installed W8.1 on.
It has an i7-2600 processor and 32 GB of memory, 1 TB SATA III hard drive.
I threw in a Radeon HD 6670 in that one.
Best Regards,
Paul -
Selecting on a Max Count of rows
I would like some advice on the following SQL. I am trying to select the max(count(*)) of a selct count(*). (if you know what I mean??)
select district_id
from (
-- retrieve a list of districts, plus the count of employee related records
select d.district_id, count(*) CountX
from station s, division d
where s.resp_empl_num = :empID and
s.stn_status_code = 'AC' and
s.resp_div_num = d.division_code
group by d.district_id
-- match on the district with the max count #
where CountX = (
select max(count(*))
from station st, division dv
where st.resp_empl_num = :empID and
st.stn_status_code = 'AC' and
st.resp_div_num = dv.division_code
group by dv.district_id
)Try this
select district_id
from ( select district_id,
rank() over (order by count(*) desc) rn
from station s, division d
where s.resp_empl_num = :empID and
s.stn_status_code = 'AC' and
s.resp_div_num = d.division_code
group by d.district_id
) where rn=1
; -
How to dynamically set Min count and Max Count values in Adobe Print Form?
How to set the Min Count and Max Count values dynamically in a Print Form?
The values when set should over ride the values set in Binding Tab.
This is all needed to print multiple Material Number labels on a single page - and the number of labels to be printed needs to be under user control - something like an Avery Address labels
Please advise.
Thanks,Here is a work around that works for me and may not be an intelligent solution .
I kept the Min Count to 1 on the subform binding properties.
Per the number of labels required, I appended the same item to the internal table so many times and passed it to the label.
it works fine for my requirement.
However - leaving out the post for a while to see if this can be done at the form level via scripting.
Thanks, -
[SOLVED] makepkg gives "grep: invalid max count"
[thiderman@justitia dunst-git]$ makepkg
==> Making package: dunst-git 1.0.0.554.92cda43-1 (Sat Dec 28 16:52:48 CET 2013)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Updating dunst git repo...
Fetching origin
==> Validating source files with md5sums...
dunst ... Skipped
==> Validating source files with sha256sums...
dunst ... Skipped
==> Extracting sources...
-> Creating working copy of dunst git repo...
Cloning into 'dunst'...
done.
==> Starting pkgver()...
==> Starting prepare()...
==> Removing existing pkg/ directory...
==> Starting build()...
dunst build options:
CFLAGS = -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os -D_FORTIFY_SOURCE=2 -D_BSD_SOURCE -DVERSION="v1.0.0-30-g92cda43" -DXINERAMA -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
LDFLAGS = -Wl,-O1,--sort-common,--as-needed,-z,relro -lm -L/usr/lib/X11 -lXss -lXinerama -ldbus-1 -lX11 -lfreetype -lXext -lXft -lXss -lgio-2.0 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lxdg-basedir
CC = cc
creating config.h from config.def.h
CC -c x.c
grep: invalid max count
Makefile:31: recipe for target 'x.o' failed
make: *** [x.o] Error 2
==> ERROR: A failure occurred in build().
Aborting...
[thiderman@justitia dunst-git]$
This has happened to me for a while. I've tried building st-git and dunst-git from the AUR, and they both die with similar stacktraces. The output shown above is run in a bash with stock configuration, so no aliases or other shell trickery is going on. I've searched both source trees, but can't even find any mention of "grep" in any of them.
Googling suggested that a file with a name starting with "-m" has been found, but I can't find any of these either.
wat do?
Last edited by Daethorian (2013-12-28 17:16:25)Trilby wrote:See my edit above - but also I'd suggest removing all the "@" signs from the makefile to see what the actual command is that is failing.
It looks pretty much exactly the same:
dunst build options:
CFLAGS = -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os -D_BSD_SOURCE -DVERSION="v1.0.0-30-g92cda43" -DXINERAMA -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
LDFLAGS = -lm -L -lXss -lXinerama -ldbus-1 -lX11 -lfreetype -lXext -lXft -lXss -lgio-2.0 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lxdg-basedir
CC = cc
cc -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os -D_BSD_SOURCE -DVERSION="v1.0.0-30-g92cda43" -DXINERAMA -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16
CC -c x.c
grep: invalid option -- 'g'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Makefile:31: recipe for target 'x.o' failed
make: *** [x.o] Error 2 -
Avg/sum/min/max/count
Is there anyway to see the avg/sum/min/max/count when you highlight a bunch of cells? I can't figure out if iPad numbers has this function. I've read several articles that mention it.
Also, I am having trouble with some formulas, does anyone know where I might get help on that?Download *_Numbers User Guide_* and *_iWork Formulas and Functions User Guide_*
You may do that from the Help menu of the version running on a mac.
You may also download them thru :
http://support.apple.com/en_US/manuals/#iwork
You will be able to select the language used.
I don't know if there are guides specific to the ipad versions.
Yvan KOENIG (VALLAURIS, France) samedi 15 mai 2010 16:39:57 -
Hello
Can anyone help with a max count query?
I'm trying to display houses that have had the most viewings by house type.
I need to do a count on viewing date, then display the max count value per group (type_description).
This is what I have so far:
select property.property_id, count(viewing.viewing_date), property_type.type_description
from property, viewing, property_type
where property.property_id = viewing.property_id
and (property.prop_type_id = property_type.prop_type_id)
However, I am not sure how to say I want to display the max count by type_description.
regards
Joactually, I'm afraid I don't follow the linked thread at all. I think it's perhaps because I haven't created any views. It's clearly the same assignment, but it looks like an incredibly complicated approach. I am obviously a bit dimmer than my course-mate!
is there another, simpler way of finding the max count and then grouping by type? -
Max, count of hits in search help
Hi all,
per default the maximum count of hits in a search help is 500. I know one can change that directly in the WD4A application, on the search help popup at settings. But is it possible to set this count to another value directly in SAP, system wide, for every user?
Kind regards, MatthiasYou are correct that it appears that you can't change all of the system-wide defaults. You can change the Maximum Width and the Display type but not the max. number of hits to be displayed.
I did some digging and this value appears to be controlled by a constant c_maxrecords in the class CL_F4CUSTOM. I tried changing this value after it is set in the CLASS_CONSTRUCTOR using the debugger. It actually is possible, but only up to a value of 999. If you go larger, you get a field overflow on the screen display field - so I assume the designer of this functionality never really intended for customers to change the value of this constant. -
Combine seperate lookupsets - find max(), count()?
Hello, my knowledge of SSRS is intermediate. Enough to have a plan. But I need just a little assistance.
Here are the functions.
here are my three lookupsets:
-LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value, “AccountActivities”)
-LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value, “AccountContactActivities”)
-LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value, “AccountOpportunityActivities”)
1) How could I find the 'Max()' of all three of these datasets. The single highest number.
2) How could I find the 'COUNT()' of all three of these datasets. The total number of rows.
If they can be done separately and then added together using variables, that is an acceptable solution. Still, I'm just learning syntax here.
THanksHi ebs_software,
According to your description, you used three lookupset function to retrieve data from other dataset, now you want to select max value and count of values of all three datasets.
I tested the issue in my local machine, we could not select sum and max value returned by lookupset function directly. To workaround this issue, we need to use custom code. For detail information, please refer to the following document:
1. Right-click outside of the report, click Report Properties.
2. Click Code in left pane, type the code like below:
Public Function AggLookup(ByVal choice as String, ByVal items as Object)
If items is Nothing then
Return Nothing
End If
Dim current as Decimal
Dim sum as Decimal
Dim count as Integer
Dim min as Decimal
Dim max as Decimal
Dim err as String
current = 0
sum = 0
count = 0
err = ""
For each item as Object in items
'Calculate count
count += 1
'Check value is a number
If IsNumeric(item) then
'Set current
current = Convert.ToDecimal(item)
'Calculate sum
sum += current
'Calculate min
If min = Nothing then
min = current
End If
If Min >current then
min = current
End If
'Calculate max
If max = Nothing then
max = current
End If
If max < current then
max = current
End If
'Return NaN if value is not a number
Else
err = "NaN"
End If
Next
'Select and set output based on the user choice or choice passed by function
If err = "NaN" then
If choice = "count" then
Return count
Else
Return err
End If
Else
Select Case choice
Case "sum"
Return sum
Case "count"
Return count
Case "min"
Return min
Case "max"
Return max
Case "avg"
'Calculate the average avoiding divide by zero errors
If count > 0 then
Return sum / count
Else
Return 0
End If
End Select
End If
End Function
3. Right-click handle of the column you want to count values returned by lookupset function, click Expression.
4. In Expression text box, type the expression like below:
=LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountActivities").Length + LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountContactActivities").Length + LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountOpportunityActivities").Length
5. Right-click handle of the column you want to calculate total of values returned by lookupset function, click Expression.
6. In Expression text box, type the expression like below:
=Code.AggLookup("sum",LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountActivities"))
7. Right-click handle of the column you want to select max value returned by lookupset function, click Expression.
8. In Expression text box, type the expression like below:
=Code.AggLookup("max",LookupSet(Fields!name.Value, Fields!name.Value, Fields!act_actualend.Value,"AccountActivities"))
The following screenshot is for your reference:
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here.
Wendy Fu
TechNet Community Support -
Diadem V9.1 / DAC / DAQ6036 / MAX / Counter OUT
I'd like to generate a continuous pulse train in Diadem DAC! I already configured in MAX (V4.0) a COUNTER OUT as "Global Virtuell DAQmx Channel" but I can't
see the Channel in Diadem DAQ-DLL-OUT block!
All AO, DO are visible in this block!
Thanks for help!Hi Gunter,
Currently we only support counter input functions such as counting, frequency- or pulsewidth measurements.
The possibility to use those counters for common output operations as pulse train generation, PWM,... is not possible at this time.
A workaround would be a signalgeneration in DIAdem and a output via Digital Out. But be aware that timing possibilities are different between realizing Counterfunctions in Hardware and Software.
Regards,
Stefan Henke
NIG -
Getting the max count for each group
Hi, I am a newbie and working on a project for school. I have been working this problem for a couple of days and made a bit of progress.
I have two tables, student and enroll for a college database. I need to show the students who have the most enrollments in each major. So far, I have:
WITH COUNT_Q AS
SELECT B.SSN, B.MAJOR, COUNT (A.CLASS_NO) AS COUNTCLASS
FROM ENROLL A, STUDENT B
WHERE A.SSN = B.SSN
GROUP BY B.SSN, B.MAJOR
SELECT MAX(COUNTCLASS), MAJOR
FROM COUNT_Q
GROUP BY MAJOR
I am getting the correct results but need to show the SSN and Major of the studens. When I add in the SSN and Major, like below, I get back too many records.
WITH COUNT_Q AS
SELECT B.NAME, B.SSN, B.MAJOR, COUNT(A.SSN) AS COUNTCLASS
FROM ENROLL A, STUDENT B
WHERE A.SSN = B.SSN
GROUP BY B.NAME, B.SSN, B.MAJOR
SELECT *
FROM COUNT_Q
WHERE (COUNTCLASS) IN (SELECT MAX(COUNTCLASS)
FROM COUNT_Q
GROUP BY MAJOR
Can someone help point me in the right direction?SELECT B.NAME,
B.SSN,
B.MAJOR
FROM (
SELECT B.NAME,
B.SSN,
B.MAJOR,
COUNT(A.CLASS_NO) SSN_MAJOR_COUNTCLASS
DENSE_RANK() OVER(PARTITION BY MAJOR ORDER BY COUNT(A.CLASS_NO) DESC) RNK
FROM ENROLL A,
STUDENT B
WHERE A.SSN = B.SSN
GROUP BY B.NAME,
B.SSN,
B.MAJOR
WHERE RNK = 1
/SY.
Edited by: Solomon Yakobson on Mar 27, 2011 6:53 PM -
Given this info:
ID Name Class ID Location ID Location Name
101 John Smith 1001 1A Location 1
101 John Smith 2002 2B Location 2
101 John Smith 3003 2B Location 2
101 John Smith 4004 3C Location 3I want to be able to get this output:
ID Name Max Location
101 John Smith Location 2 Using this:
Select id, name, MAX("Amt") from (select id, name,
(case when location_id = '1A' then Count(pidm_key)
when location_id = '2B' then Count(pidm_key)
when location_id = '3C' then Count(pidm_key) else null end) "Amt"
from Table1
group by id, name, location_id)
group by id, name
I get:
ID Name Amt
101 John Smith 2 But of course I want the other output.What is you db version?
you can use the KEEP syntax for the max aggregate in the outer query.
Along the lines of
not syntax checked
MAX(location_name) keep (dense_rank last order by "Amt") -
Howto limit max. count of rows in a TABLES-based import-parameter?
Hello all,
I have created a web service based on a custom function module in SAP. Beside others this function module provides one TABLES input parameter, which is set to "optional". Now I want to publish the web service with this parameter optionally as well, but also allow it for max. 10 tmes (meaning max. 10 rows for this import table).
I have found an entry for min and max settings in SE80 for this web service, but unfortunately these both fields are read-only, so I can't set the maxOccurs here.
Any ideas how I can solve this problem?
Thanks in advance for your help!
Kind regards, Matthias
Edited by: Matthias F. Brandstetter on Oct 21, 2010 10:32 AMHi,
It is not possible to change SAP generated service. Better you create new service in ESR and assign correct maxOccurs and then create proxy of this service in backend where you can also map ESR service to FM.
To minimize effort you can copy same wsdl and then change wsdl and import in ESR as new service.
Regards,
Gourav -
Get the max count of the column list item
Hi,
I have a list with the 'TO' column of type people. My task is to get persons name who is featured the max number of time in the 'TO' column.
What is the best possible solution OOB. I dont want to go with custom solution.
Thanks,
AnkitHello Ankit,
I understand that you want to get total of "To" column. I would suggest you modify the current view of list and use "Group By" and Total section to get Max number of that column. Just try this and check whether it fulfils your need or
not.
Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Max count of ThinkVision connected to a X220?
Hi!
I have here a X220 Tablet and a nice Lenovo ThinkVision LT1421. It would be nice to connect some more of the Lenovo ThinkVision LT1421 to my X220.
How many of the Lenovo ThinkVision LT1421 can I connect at the same time?
Any Limitation?I checked my x220 and connected 3xLT1421 and LT2252p - it was working fine (all 5 displays - including x220 built-in display)
LT1421 is a DisplayLink USB device and this technology standard allows up to 6 USB displays connected to a PC, and up to 4 displays to Mac. Under Windows Multipoint Server, up to 14 USB clients are supported.
Maybe you are looking for
-
Sos_9iAS(9.0.3) on RHAS2.1
following the docs of oracle... at the end of installion--configuration tools stage,the 'OC4J Instance Configuration Assistant' item can't work.it says: Reading ini file - '/app/oracle/product/9.0.3/j2ee/deploy.ini' OC4J instance 'OC4J_Demos': Adding
-
HP Printer Assistant Software Missing Scan Option on DeskJet 2542
I have installed the Printer Assistant Software on both an HP Desktop and a Lenovo Laptop. I have two HP DeskJet 2542 Printers in two different physical loactions that I connect to with the Laptop. On the Desktop computer the install of the softwar
-
Photoshop CS5 does not recognize many AVI codecs
I'm extensively using my Win7 PS-CS5 for automated rotoscoping of AVI video, but I have been frustrated by its skimpy support for AVI export codecs. My other video applications, including cheap ones, give me so many codec options not recognized by CS
-
HI! I'd like to generate java stub classes by using the WSDL document. After parsing the WSDL document, a java class with all available method calls should be created. With IBM WebService Development Kit this is possible with the Apache Axis project
-
Cycle keystroke not doing what it's supposed to
checked keystrokes and it says that cycle is "/" (like it was in 7) and when i press "/" i get the "go to position" box. am i doing something wrong? anyone else getting this? thanks