我试图获得2008年第一次生产作品的国家名单 这是我的sql req:
SELECT DISTINCT *
FROM pays p
WHERE p.id_pays != (
SELECT DISTINCT pays.id_pays
FROM pays
JOIN emission ON emission.id_pays = pays.id_pays
WHERE MIN(YEAR(emission.dateFrappe_emission)) != 2008
)
它让我回答:
" #1111 - 无效使用群组功能";
但是这个res可以工作:
SELECT DISTINCT *
FROM pays p
WHERE p.id_pays != (
SELECT DISTINCT pays.id_pays
FROM pays
JOIN emission ON emission.id_pays = pays.id_pays
WHERE YEAR(emission.dateFrappe_emission) = 2008
)
你能帮帮我吗?
答案 0 :(得分:3)
您可以将聚合函数与SELECT
和HAVING
子句一起使用,例如:
SELECT DISTINCT *
FROM pays p
WHERE p.id_pays NOT IN (SELECT pays.id_pays
FROM pays
JOIN emission
ON emission.id_pays = pays.id_pays
GROUP BY pays.id_pays
HAVING MIN(YEAR(emission.dateFrappe_emission)) != 2008 )
答案 1 :(得分:2)
2008年首次投产?这不是简单的:
$(document).ready(function() {
var max_fields = 10; //maximum input boxes allowed
$(".add_field_button").click(function(e){ //on add input button click
e.preventDefault();
var add_button = $(this);
var fieldset = add_button.closest('fieldset');
var wrapper = add_button.closest('.sf-viewport');
var form = add_button.closest('form');
var x = parseInt(fieldset.attr('data-count'));
var cur_height = 0;
var fieldset_clone;
var fieldset_content;
if(x < max_fields){ //max input box allowed
//text box increment
fieldset.attr('data-count',x+1);
cur_height = fieldset.height();
form.height(cur_height*2);
wrapper.height(cur_height*2);
fieldset_clone = add_button
.closest('fieldset')
.find('.fieldset-content')
.eq(0)
.clone();
fieldset_clone
.find('[name]')
.each(function(){
$(this).val($(this).prop('defaultValue'));
});
fieldset_content = $('<div>')
.addClass('fieldset-content')
.append(fieldset_clone.children());
// add_button.before(fieldset_clone.children());
add_button.before(fieldset_content);
// add remove button
add_remove_btn(fieldset_content);
}
});
function add_remove_btn(item){
item.prepend(
'<a class="btn pull-right om-remove btn-danger btn-xs" href="#">'+
' <div class="small">Remove</div>'+
'</a>'
);
}
//user click on remove text
$(document).on("click",".om-remove", function(e){
e.preventDefault();
var x = parseInt($(this)
.closest('fieldset')
.attr('data-count')
);
$(this)
.closest('fieldset')
.attr('data-count',x-1);
$(this)
.closest('.fieldset-content')
.slideUp(function(){
$(this).remove()
})
});
});