I am trying to get only one row from child table for each parent row with child fields included, I have been trying with GRUOP BY but with no success :( Here is my initial S
You didn't state your DBMS so this is a standard ANSI solution:
SELECT pID, lastname
FROM parent
LEFT JOIN (
SELECT pID,
row_number() over (partition by pid order by cid) as rn
FROM child
) as child
ON parent.pID = child.pID and child.rn = 1
Which rows you define as the "first" row is up to you. There is no such as a "first" row unless you sort the rows - that's what the part order by cid does in the partition clause. So if you want something different as the "first" row, you need to change that.
Btw: there is no need to select all columns from the child table if you don't use them.