Reputation:
Code:
SELECT ta.name AS ta_name,
ta.unit AS ta_unit,
ta.id_producer_goods AS ta_id_producer_goods
FROM Table ta
WHERE id_city = '24'
AND id_firm = '22131'
AND id_service = '5'
In select me need get rows with group by ta_name(result should include only unique ta_name) and get count of each unique ta_name in all table.
How do it?
Upvotes: 2
Views: 70
Reputation: 19
I think this may help
SELECT DISTINCT COUNT(ta.name)
, ta.name AS ta_name
, ta.unit AS ta_unit
, ta.id_producer_goods AS
ta_id_producer_goods
FROM [table] ta
WHERE id_city = '24'
AND id_firm = '22131'
AND id_service = '5'
GROUP BY
ta.name
, ta.unit
, ta.id_producer_goods
Upvotes: 0
Reputation: 958
Seems too simple--but here is what I'm understanding you need.
SELECT ta.name AS ta_name,
ta.unit AS ta_unit,
ta.id_producer_goods AS ta_id_producer_goods, COUNT(*)
FROM TABLE ta
WHERE id_city = '24'
AND id_firm = '22131'
AND id_service = '5'
GROUP BY ta.name, ta.unit, ta.id_producer_goods
Upvotes: 1