我是sql ans ms-access的新手。 所以,我有表tab1,列 id, decscription, number 我想创建一个查询,返回没有通用描述和数字的行的ID。 理想的输出是this
我试过了
SELECT id
FROM tab1
GROUP BY id, description, Number HAVING COUNT(*)=1;
但返回逻辑错误。
答案 0 :(得分:1)
如果要返回唯一的行,可以执行以下操作:
angular.module('App', ['ngCookies','ngResource','ui.router'])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: '/login',
templateUrl: "views/login.html",
data: {
required: false
}
})
.state('dashboard', {
url: '/dashboard',
templateUrl: "views/dashboard.html",
data: {
required: true
}
});
$urlRouterProvider.otherwise('/login');
})
.run(["$rootScope", "$state", "$location", "authService", "$cookies", "$sessionStorage", function ($rootScope, $state, $location, authService, $cookies, $sessionStorage) {
$rootScope.$on('$stateChangeStart', function (e, toState, toParams, fromState, fromParams) {
console.log("currentState: ", $state.current);
console.log("toState is:", toState);
if (toState.data.required && !$sessionStorage.authuserid) {
alert("state not authenticated");
e.preventDefault();
$state.go('login');
}
});
}]);
您也可以使用聚合执行此操作。获取select *
from tab1
where not exists (select 1
from tab1 as t
where tab1.description = t.description and tab1.number = t.number and
tab1.id <> t.id
);
:
id
答案 1 :(得分:0)
SELECT id
FROM tab1
GROUP BY description, Number HAVING COUNT(*)=1;
答案 2 :(得分:0)
你的问题不是很清楚,也许是:
SELECT
id, description, Count(*) As Number
FROM
tab1
GROUP BY
id, description