Hi any shortcut to combine duplicate rows to one row ?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nitin SontakkeRank #264 · 9.6K reputationPosted Oct 15, 2022, 2:32 AM EDT
You will have to show some sample data and an expected output.
Typically, DISTINCT clause is used for the purpose, however, more details are required.
Rajeev KumarRank #1,334 · 1.3K reputationPosted Mar 3, 2023, 4:50 AM EST
If you want to use a true DISTINCT only list out the column you want to receive distinct values of. If you have multiple columns then all those columns combined make up one distinct record.
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 3, 2023, 5:40 AM EST
Hello Meghana,
SQL: Use the "GROUP BY" statement to group together all rows with the same values in certain columns. Then use aggregate functions (such as SUM, AVG, or COUNT) to combine the values in other columns. For example, if you have a table with columns for "Name," "Age," and "Salary," and you want to combine all rows with the same name into one row, you could use the following SQL statement:
SELECT Name, SUM(Age), SUM(Salary) FROM MyTable GROUP BY NameThis will give you one row for each unique name, with the total age and total salary for all rows with that name.