Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sql – use (Group by) with 2 columns

I have table named (TB1) with columns (Device – Order_id – qty) ….
enter image description here

I want write sql query to show each (order No) with (device name) with (total device qty) in this order … I know we must use (group by) … But I don’t know how do that

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can group by two columns like this : group by col1, col2.
So your query should be something like:

select Device, Order_no, sum(Qty)
from table_name
group by Device, Order_no
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading