Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1b07e3b2
Commit
1b07e3b2
authored
Dec 04, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
postreview fixes
parent
a3ad1765
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
mysql-test/r/subselect_innodb.result
mysql-test/r/subselect_innodb.result
+26
-0
mysql-test/t/subselect_innodb.test
mysql-test/t/subselect_innodb.test
+13
-2
No files found.
mysql-test/r/subselect_innodb.result
View file @
1b07e3b2
...
...
@@ -114,3 +114,29 @@ SELECT R.unit, R.ingredient FROM t1 R WHERE R.ingredient IN (SELECT N.ingredient
unit ingredient
xx yy
drop table t1, t2;
CREATE TABLE t1 (
id INT NOT NULL auto_increment,
date1 DATE, coworkerid INT,
description VARCHAR(255),
sum_used DOUBLE,
sum_remaining DOUBLE,
comments VARCHAR(255),
PRIMARY KEY(id)
) engine=innodb;
insert into t1 values (NULL, '1999-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1999-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1999-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1998-01-01', 1,'test', 22, 33, 'comment'), (NULL, '1998-01-01', 1,'test', 22, 33, 'comment'), (NULL, '2004-01-01', 1,'test', 22, 33, 'comment'), (NULL, '2004-01-01', 1,'test', 22, 33, 'comment');
SELECT DISTINCT
(SELECT sum(sum_used) FROM t1 WHERE sum_used > 0 AND year(date1) <= '2004') as somallontvangsten,
(SELECT sum(sum_used) FROM t1 WHERE sum_used < 0 AND year(date1) <= '2004') as somalluitgaven
FROM t1;
somallontvangsten somalluitgaven
154 NULL
select * from t1;
id date1 coworkerid description sum_used sum_remaining comments
1 1999-01-01 1 test 22 33 comment
2 1999-01-01 1 test 22 33 comment
3 1999-01-01 1 test 22 33 comment
4 1998-01-01 1 test 22 33 comment
5 1998-01-01 1 test 22 33 comment
6 2004-01-01 1 test 22 33 comment
7 2004-01-01 1 test 22 33 comment
drop table t1;
mysql-test/t/subselect_innodb.test
View file @
1b07e3b2
...
...
@@ -129,8 +129,19 @@ drop table t1, t2;
#
# possible early unlock
#
CREATE
TABLE
t1
(
id
INT
NOT
NULL
auto_increment
,
date1
DATE
,
coworkerid
INT
,
description
VARCHAR
(
255
),
sum_used
DOUBLE
,
sum_remaining
DOUBLE
,
comments
VARCHAR
(
255
),
PRIMARY
KEY
(
id
))
engine
=
innodb
;
CREATE
TABLE
t1
(
id
INT
NOT
NULL
auto_increment
,
date1
DATE
,
coworkerid
INT
,
description
VARCHAR
(
255
),
sum_used
DOUBLE
,
sum_remaining
DOUBLE
,
comments
VARCHAR
(
255
),
PRIMARY
KEY
(
id
)
)
engine
=
innodb
;
insert
into
t1
values
(
NULL
,
'1999-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
),
(
NULL
,
'1999-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
),
(
NULL
,
'1999-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
),
(
NULL
,
'1998-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
),
(
NULL
,
'1998-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
),
(
NULL
,
'2004-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
),
(
NULL
,
'2004-01-01'
,
1
,
'test'
,
22
,
33
,
'comment'
);
SELECT
DISTINCT
(
SELECT
sum
(
sum_used
)
FROM
t1
WHERE
sum_used
>
0
AND
year
(
date1
)
<=
'2004'
)
as
somallontvangsten
,
(
SELECT
sum
(
sum_used
)
FROM
t1
WHERE
sum_used
<
0
AND
year
(
date1
)
<=
'2004'
)
as
somalluitgaven
FROM
t1
;
SELECT
DISTINCT
(
SELECT
sum
(
sum_used
)
FROM
t1
WHERE
sum_used
>
0
AND
year
(
date1
)
<=
'2004'
)
as
somallontvangsten
,
(
SELECT
sum
(
sum_used
)
FROM
t1
WHERE
sum_used
<
0
AND
year
(
date1
)
<=
'2004'
)
as
somalluitgaven
FROM
t1
;
select
*
from
t1
;
drop
table
t1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment