Show MS Access Row Value in column [duplicate] - ms-access

This question already has answers here:
How do I combine information from multiple rows (concatrelated) without getting duplicate values in my report?
(2 answers)
is there a group_concat function in ms-access?
(4 answers)
Closed 10 months ago.
i have combined Query, as below
ItemCode ItemName Qty OrderNo
100356 xxx 2 001
100355 yyy 3 002
100356 xxx 5 003
Currently the group query shows as below:
ItemCode ItemName Qty
100356 xxx 5
100355 yyy 3
I want to show as the following:
ItemCode ItemName Qty OrderNo
100356 xxx 5 001,003
100355 yyy 3 002

Related

display table using where condition [duplicate]

This question already has answers here:
MySQL ORDER BY IN()
(4 answers)
Closed 4 years ago.
I am trying to display the table using where condition on id column, but when I run the query the query, the table displays without where condition
Table: test
id name
1 aaa
2 bbb
3 ccc
I want to display the table like below :
Select * from test where id in ('2','3','1')
when I run the above query it is displayed as failing where condition.
1. aaa
2. bbb
3. ccc
try below query
select * from test
where id in (2,3,1)
order by
case id
when 2 then 1
when 3 then 2
when 1 then 3
end
here is the link for db-fiddle
Try this
SELECT
*
FROM
test
WHERE
id in ('2','3','1')
ORDER BY FIELD(id,'2','3','1');

Calculate Total Number of Row's Value [duplicate]

This question already has answers here:
mysql count the sum of all rows
(6 answers)
Closed 6 years ago.
I have a SQL table that looks like this:
id | value
-----------------------
1 | 5
2 | 5
3 | 6
I want to count the value of every rows.
In this example the output should be 16.
What query should I use to count the total value of the rows?
You can learn more about COUNT() Function there.
https://www.w3schools.com/sql/sql_func_count.asp

How do I compare two rows and find the greater of the two in a set of many pairs? [duplicate]

This question already has answers here:
SQL select only rows with max value on a column [duplicate]
(27 answers)
Closed 7 years ago.
Alright, so I have a table of persons and each person belongs to a couple. I need to run a query that gets only the older member of each couple. Here is my schema:
id BIGINT
name VARCHAR(32)
couple_id VARCHAR(255)
birthdate TIMESTAMP
And the query I'm working on:
SELECT * FROM person
GROUP BY couple_id
HAVING birthdate > ???
The couple_id is a randomized string. Currently the output looks like this:
1 John AAA 1985/12/04
2 Jane AAA 1984/01/02
3 Christopher BBB 1991/07/07
4 Christina BBB 1992/08/20
5 Alex CCC 1995/02/07
6 Alexandra CCC 1996/11/12
I need a query that returns the rows John, Christina, and Alexandra.
One way to do it is using a derived table.
SELECT p1.*
FROM person p1
join (select couple_id, max(birthdate) as mxbrthdt
from person group by couple_id) p2
on p2.couple_id = p1.couple_id and p1.birthdate = p2.mxbrthdt

Does anyone know how to Stuff in groups? [duplicate]

This question already has answers here:
Can I concatenate multiple MySQL rows into one field?
(16 answers)
Closed 9 years ago.
I am trying to use the stuff function in MS SQL to stuff certain info. Here is the example:
Number Value
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
I would like to stuff the column so that only one record will display as following:
Value Number
1 1,2,3
2 1,2,3
3 1,2
Please note that there are a like n-Numbers and n-Values.
You can use GROUP_CONCAT for this. For example:
SELECT `Value`, GROUP_CONCAT(DISTINCT `Number` ORDER BY `Number`)
FROM `yourTable`
GROUP BY `Value`

Make comma separate values with single column in mysql [duplicate]

This question already has an answer here:
MySQL : Multiple row as comma separated single row
(1 answer)
Closed 9 years ago.
Here is my table information
Id Name
1 aaa
1 bbb
2 ccc
2 ddd
Ids are the repeated one. Now I want the result like
1 aaa,bbb
2 ccc,ddd
How can I do that in Mysql ?
Use GROUP_CONCAT()
select id, group_concat(name) as names
from your_table
group by id