I am trying to get records from 5 tables , and finally i have done it but now i want unique records , so what should i change in my query?
SELECT
t.*,
sh.invoice_Number AS sale_inv_no,
sh.invoice_date AS sale_inv_date,
sh.from_Date AS sale_from,
sh.to_Date AS sale_to,
sh.number_Of_Months AS sale_nom,
c.cName AS cust_name,
h.hName AS ho_name,
[hSize1] & 'X' & [hSize2] & '=' & [hSize_SQF] AS ho_size,
h.hLocation AS ho_loc,
c.cMobile AS cust_mob,
f.firmName AS firm_name
FROM
(
(
(
adv_tbl_transactions AS t
RIGHT JOIN
adv_tbl_Sale_Hoardings AS sh
ON t.tra_code = sh.transaction_code
) LEFT JOIN adv_tbl_Hoardings AS h
ON sh.hid = h.ID
) LEFT JOIN tbl_Firms AS f
ON sh.e_fid = f.ID
) LEFT JOIN tbl_Customers AS c
ON sh.cid = c.ID
WHERE
(((t.e_fid)=1));
it gives me output like below
srNo | Hoarding | customers | transaction details | advance | balance | total
1 | Name: h1 | Cust1 | inv no : 1 | 6000 | 1000 | 70000
2 | Name: h1 | Cust1 | inv no : 1 | 6000 | 1000 | 70000
3 | Name: h2 | Cust2 | inv no : 2 | 3000 | 1000 | 40000
4 | Name: h2 | Cust2 | inv no : 2 | 3000 | 1000 | 40000
I want to output like below
srNo | Hoarding | customers | transaction details | advance | balance | total
1 | Name: h1 | Cust1 | inv no : 1 | 6000 | 1000 | 70000
2 | Name: h2 | Cust2 | inv no : 2 | 3000 | 1000 | 40000
i want distict column entry_no
Use distinct
keyword:
select distinct t.*,
sh.invoice_Number AS sale_inv_no,
sh.invoice_date AS sale_inv_date,
sh.from_Date AS sale_from,
sh.to_Date AS sale_to,
sh.number_Of_Months AS sale_nom,
c.cName AS cust_name,
h.hName AS ho_name,
[hSize1] & 'X' & [hSize2] & '=' & [hSize_SQF] AS ho_size,
h.hLocation AS ho_loc,
c.cMobile AS cust_mob,
f.firmName AS firm_name
FROM (((adv_tbl_transactions AS t
RIGHT JOIN adv_tbl_Sale_Hoardings AS sh
ON t.tra_code = sh.transaction_code)
LEFT JOIN adv_tbl_Hoardings AS h
ON sh.hid = h.ID)
LEFT JOIN tbl_Firms AS f ON sh.e_fid = f.ID)
LEFT JOIN tbl_Customers AS c
ON sh.cid = c.ID
WHERE (((t.e_fid)=1)) ;
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.