Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Can someone help in coding a Access SQL statement/Query where I have a table with columns as shown with Ident No not primary
Ident_No-----Data1-----Data2-----Data3-----Data4-----Data5-----Data6
1----------------abc--------def---------null---------null--------null--------null
1----------------null--------null---------ghi----------jkl----------null--------null
1----------------null--------null---------null---------null--------mno--------pqr
Looking for result as shown below in the query result or a new table.
Ident_No-----Data1-----Data2-----Data3-----Data4-----Data5-----Data6
1----------------abc--------def---------ghi---------jkl--------mno--------pqr
Please Help Thanks in advance
You need to use group by and get the MAX() value for each column like
select `Ident_No`, max(`Data1`), max(`Data2`),
max(`Data3`), max(`Data4`), max(`Data5`), max(`Data6`)
from tbl9999
group by Ident_No
See live here http://rextester.com/CIHY78216
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I have to take over old colleague's code and trying to understand this one SQL statement like below:
SELECT * FROM my_table WHERE date_key = '{0}'
Column date_keycontains int values such as 20220712, 20220120, etc.
The first guess is that SELECT statement filters for rows with 0 value in column date_key. However, when running that line of code, I receive this error :
SQL Error [100038] [22018]: Numeric value '{0}' is not recognized
What exactly does that line of code do?
That looks like a placeholder, replaced with an actual value in code when calling the query.
See similar What is {0},{1},{2},{3} in the SQL query
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I am bit new this, can someone please help me to rectify this error. I am using sqllite:
The table name in the INSERT is wrong. And the column list must match the values list.
Try INSERT correct table name (target columns) Values (vales for each column).
Additionally if you omit any columns the insert will fail unless they have defaults.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
CrimeData Table for 12 months
Crime Took place in Easternmost
I need to find the following:
Q.7 What type of Crime takes place in the …
(a) Easternmost ………………..
(b) Westernmost ………………..
(c) Northernmost………………..
(d) Southernmost………………..
I tried to find the crime took place in the Easternmost using the following SQL code
SELECT Max(CrimeData.Easting) AS MaxOfEasting, CrimeData.Type
FROM CrimeData
GROUP BY CrimeData.Type;
but I got more than one crime and also other Easting numbers. Can you please tell me if there are other good ways to find the solution.
Please see the attached pictures :)
Rather than using Max/Min, have a look at the TOP keyword in SQL. Some SQL might look like:
SELECT TOP 1 CD.*
FROM CrimeData CD
ORDER BY CD.Easting DESC;
Regards,
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I Couldn't find the value that has 'r' in the third position using LIKE operation in SQL.
could anyone help me, please?
I think it would be better to write something like this.
SELECT <column>, FROM <table> WHERE <condition> LIKE "__r%";
EDIT:
This is tested and functional for SQL Server and Oracle DBMSs.
SELECT * FROM <table> WHERE substring(<column>,3,1) = 'r'
Try this. This is using SQL Server which will yield the result you are looking for.
You want to get the r from 'scr' with position 3
Try this
SELECT * FROM Customers
WHERE CustomerName LIKE '__r%';
position is count of _.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a table like.
And i want to answer like a table below:-
I think you want to use aggregation, like this:
select empcode, coode, finyear, wef,
max(cl_opn_bal) as cl_open_bal,
. . .
from table t
group by empcode, coode, finyear, wef;