mysql – Selecting a value from a row where another column is max

I have the following SQL query:

SELECT bug.`id`,
FROM   `bug`
       LEFT OUTER JOIN `stacktrace`
                    ON ( stacktrace.`bug_id` = bug.`id` )
       CROSS JOIN `version`
                  LEFT OUTER JOIN `report`
                               ON ( report.`stacktrace_id` = stacktrace.`id` )
WHERE  stacktrace.`version_id` = version.`id`
GROUP  BY bug.`id`
ORDER  BY Max(report.`date`) DESC; 

I now want to select instead of version.code from the row where version.code is maximal. Is this possible? If so, how do I do this with minimal amount of queries/overhead?

Relevant Tables (stripped):

  PRIMARY KEY (`id`)


CREATE TABLE `version` (
  `code` int(11) NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)

CREATE TABLE `stacktrace` (
  `bug_id` int(11) NOT NULL,
  `version_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_s_v` (`version_id`),
  KEY `FK_s_b` (`bug_id`),
  CONSTRAINT `FK_s_v` FOREIGN KEY (`version_id`) REFERENCES `version` (`id`) ON DELETE CASCADE

CREATE TABLE `report` (
  `id` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` datetime NOT NULL,
  `stacktrace_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_r_s` (`stacktrace_id`),
  CONSTRAINT `FK_r_s` FOREIGN KEY (`stacktrace_id`) REFERENCES `stacktrace` (`id`) ON DELETE CASCADE

As SQLFiddle

How to construct a directed graph to compute its max flow if its undirected AND with vertex capacities

Suppose we are given this graph:

enter image description here

If I want to calculate its max flow. My guess would be that I need to first convert the weighted vertices into unweighted vertices by doing something like this:

enter image description here

And since this is not a directed graph, I assume we that I need to create 2 symmetric edges per “regular” edge. However, this is where I get stuck because I am not sure where exactly those edges are suppose to connect with the “in” and “out” vertices I created earlier.

Help would be very appreciated. Thank you.

Agregar atributo max con valor AJAX

Cordial saludo,

Tengo este problema, despues de seleccionar algunos datos SELECT se debe cargar un atributo MAX con un dato arrojado por una consulta de un AJAX. Hice lo siguiente pero solo obtengo agregar el atributo pero con (objet Object) como valor. Agradezco su ayuda de antemano.

  $('#estado1').on('change', function(){
    if($('#estado1').val() == ""){
    } else {
      var valort = $('#cantidad').load('ajaxdata2.php?idproducto1='+$('#idproducto1').val()+'&estado1='+$('#estado1').val());
      $('#cantidad').attr('max', valort);

plugins – Issue with LearnPress and WooCommerce – Max Coach Theme

I am building a site on wordpress. I am using Max Coach theme which includes Learnpress and WooCommerce as main plugins.

The website consists of online courses and once the buy now button is clicked it says your cart is empty.

I integrated the Learpress Woo Payment plugin to add Razorpay payment gateway to learnpress.

Please help

java – Find max non-adjacent element subset sum

This question is regarding this hackerrank problem which has the following statement:

Given an array of integers, find the subset of non-adjacent elements with the maximum sum. Calculate the sum of that subset.

This seems similar to the Subset Sum Problem but I’m still not being able to solve it.

This is my current solution, based on the idea of considering the current element as part of the solution or not (and in the former case just skip the next element):

    static int maxSubsetSum(int() arr, int i, Integer() m) {
        if (i < 0) return 0;
        if (m(i) != null) return m(i);

        int sol1 = arr(i) + maxSubsetSum(arr, i-2, m);
        int sol2 = maxSubsetSum(arr, i-1, m);

        int result = Math.max(sol1, sol2);
        m(i) = result;
        return result;

    static int maxSubsetSum(int() arr) {
        return maxSubsetSum(arr, arr.length - 1, new Integer(arr.length));

I’m getting a Runtime Error and I don’t understand why. Do you see something weird with this implementation?

Thanks in advance.

plugins – FacetWP – change number range “Min” and “Max” labels independently

I have a slight problem for renaming facets individually
as said here on this page,
this code rename all the min and max for all facets range number.


// Add to your (child) theme's functions.php

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
    if ( 'fwp-front' == $domain ) {
        if ( 'Min' == $translated_text ) {
            $translated_text = 'Min (translated)';
        elseif ( 'Max' == $translated_text ) {
            $translated_text = 'Max (translated)';
    return $translated_text;
}, 10, 3 );

I have a facet price and another area.

I would like to rename their placeholders independently.

if somebody understands the code which line I must add to allow me this modification?

thank you for your patience

Will using a lens at max aperture (“wide open”) result in poor images?

The performance of a lens at maximum aperture really boils down to two things: lens element material and lens element and group construction. A “lens” as we commonly refer to in the DSLR world is actually a collection of individual glass lens elements, often grouped into related sets. There are a wide variety of type of individual lens elements that aim to control optical aberrations and refract light appropriately so an image can be focused clearly onto the image plane. These lens elements include your standard convex, concave, and partial convex/concave lenses that normally refract light, apochromatic, achromatic doublet, and diffractive lenses designed to correct chromatic aberrations, aspheric lenses designed to correct spherical aberrations, high density glass or glass alternatives used to refract light with less aberration, ultra low dispersion glass to reduce dispersion (and therefor chromatic aberration), etc.

A cheaper lens will use cheaper lens elements, and have fewer correcting groups designed to eliminate optical aberrations such as chromatic aberration, spherical aberration, distortion, and a few others. For cheaper quality f/1.4 lenses, used wide open, you are most likely to encounter chromatic aberration, which usually presents as color fringing. You may also encounter focus shift problems as you stop down the aperture in a cheaper lens, due to spherical aberration. In some cases, spherical aberration is a desirable attribute, as it creates extremely soft bokeh (background blur circles). Such a trait is particularly desirable in portrait lenses. Simpler lenses with fewer elements have the potential to offer superior sharpness, as the more lens elements, the more compromises you will ultimately have to make. This superior sharpness is usually only realized when the lens is stopped down beyond f/2.8, however, due to the lack of correction for optical aberrations at wider apertures.

A more expensive lens will usually use higher quality glass, and include elements with ultra high density/ultra low dispersion elements, apochromatic and/or apsherical lens elements, and possibly lens elements made of flint or flourite. There will often be more corrective groups in a higher quality lens to maximize control over how light refracts, disperses, and focuses. Lens elements in a high quality lens will also sport high quality multicoating to eliminate lens flaring and ghosting, which results in a sharper image than with lens elements that are not multicoated. (Cheaper lenses will usually include multicoated front and back lens elements, but may not include multicoated lenses for all elements.) A top of the line fast prime, while it will still exhibit some optical aberrations wide open, will usually be FAR superior to a cheap lens. The background bokeh of a quality lens is also usually much more desirable as the design of the lens diaphram is usually more advanced as well, with more blades, curved blades to avoid polygonal out-of-focus circles, etc.

When it comes to lens quality, you ultimately get what you pay for. If you need top of the line, wide-open performance, you’re going to need a top of the line lens that is designed to deliver top of the line wide-open performance. This would be the case if you were doing portrait or wedding photography for a living, and needed that optimal bokeh at f/1.4 (or f/1.2 even) for superb facial portraits. If you need a fast lens, but will mostly use it for night photography or in situations where capturing supreme focus with ideal background blur is not key factor, then an f/1.4 that has moderate bokeh some chromatic aberration issues wide open will likely not be an issue.

These days, most f/1.8 lenses offer decent quality wide open, and pretty fantastic quality when stopped down past f/2.8 (and up the the diffraction limit of the camera, which usually falls around f/8 or so.) There are a variety of f/1.4 lenses from several brands, ranging from pretty cheap to really high quality. A middle-ground f/1.4 lens can be had for about $500 or so that will deliver very acceptable quality wide open, and better stopped down a bit (most lenses improve in sharpness when the aperture is closed down by a stop or two.) If you want the best quality as wide as you can get it, most big name brands like Nikon and Canon, as well as Zeiss, make very expensive, very wide lenses (as wide as f/1.2) that offer unsurpassed quality from their widest aperture through f/2.8, and possibly beyond. You’ll have to pay for this quality, though, as these lenses usually roll in for around $2k.

An interesting consequence of achieving maximum wide-open quality, however, is often less than maximal quality through the “middle” aperture range, from f/2.8 through the diffraction limit. Compare a cheap $90 nifty fifty f/1.8 at f/4 to a $2000 f/1.2 at f/4, and the cheap lens will probably edge out the expensive lens in the area of sharpness. The additional and non-standard lens elements (like apochromatic, aspherical, etc.) can correct optical aberrations wide open, but usually at the cost of some sharpness. The higher quality lens, despite having slightly lower sharpness, will still usually provide superior color, contrast, and clarity.

Help in SQL query for beginners, max of column

I have 2 tables, one holds questions the other holds answers to the questions, each answer has a number of likes, I need to print each question with its most liked answer.
I have added a picture to show elaborate the question better.
enter image description here

the code I have written so far and does not work well:

SELECT q.q_text,a.a_text

FROM answers as a
JOIN questions AS q
on a.q_id =

WHERE (SELECT max(answers.likes) from answers)

plotting – Min & Max value for colorbar doesn’t match DensityPlot



It produces:

enter image description here

Now let’s say that I am only interested on P_C when it is bigger than 4. All things below 4 should be dark purple and the colored only be used for 4 and higher values. I thought that doing the following would do the correct output.


Unfortunately it doesnt:

enter image description here

The colors used on the plot are basically totally uncorrelated from the color bar. How can I fix it ?

(edit) I did what is proposed in the comment but it doesn’t fix the issue:


enter image description here

Also, please I would like to have explanations about the command. I looked at the documentation of the ColorScaling but it is not really helpfull.