简体   繁体   中英

SQL query with left join with where condition

please help me to correct this query, I need the data with this that senderId

select count(tg."transferGroupId"),
       tg."transferGroupId",
       tg."senderId",
       tg."receiverId",
       tg."createdAt",
       u."firstName" 
from kit.kit_transfers as tg 
where tg."senderId"='30b81071-0167-4736-a162-103a2165be3d' 
left join users as u on tg."receiverId"=u.id 
group by tg."transferGroupId",  tg."senderId",tg."receiverId",tg."createdAt",u."firstName"
select count(tg."transferGroupId"),
       tg."transferGroupId",
       tg."senderId",
       tg."receiverId",
       tg."createdAt",
       u."firstName"
from kit.kit_transfers as tg
left join users as u on tg."receiverId"=u.id
where tg."senderId"='30b81071-0167-4736-a162-103a2165be3d'
group by tg."transferGroupId",  tg."senderId",tg."receiverId",tg."createdAt",u."firstName"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM