I am trying to select multiple values from the same table. I need to select count values of the column rfid and process_status from the posts table and station_title from stations table.
Here are the two tables:
Posts table : Id ownerId rfid stationId stationType process_status
1 107 rfid1 raj1222681607 like pending
2 107 rfid1 raj1222681607 like pending
3 107 rfid1 raj1125396157 like pending
4 107 rfid1 raj1222681607 like
5 107 rfid2 raj1222681607 like pending
6 107 rfid3 raj1222681607 like
Stations table : Id title ownerId stationId stationLike stationPic
1 Check-in one 107 raj1125396157 1 0
2 nfc station 01 107 raj1222681607 1 0
From these two tables I want to fetch data as Total RFIDs : 5 Total Pending : 3 Station Title : nfc station 01
The where clause conditions are : ownerId = 107 and the stationId = 'raj1222681607' and the process_status = 'pending'
So far I can achieve the total rfids, station title value; but i am not able to get the total pending value counting the process status.
My query snippet:
SELECT
COUNT(p.rfid) as TotalTap,
COUNT(p.process_status) as TotalPending,
s.title
FROM posts p
inner join
stations s
on p.stationId = s.stationId
WHERE
p.ownerId = 107 AND p.stationId = 'raj1222681607'
AND p.process_status = 'pending';
But this is giving the wrong output as : Total RFIDs : 3 (THIS IS WRONG!!) Total Pending : 3 Station Title : nfc station 01
Thanks in advance for your help.
Aucun commentaire:
Enregistrer un commentaire