Click here to Skip to main content
15,911,531 members

Comments by SM6TOB (Top 6 by date)

SM6TOB 24-Apr-22 12:01pm View    
Here in Sweden we use all kinf of "extra" words, but my misstake. The intended word was "horse"
SM6TOB 23-Apr-22 13:20pm View    
I dont know the practise here, but i have a way for a solution. This could be a new question but i'll add it here.

I have a beast of a query which gives me a total unique areas and the date for te last unique one.
How do i alter/rewrite this query to list all users(mycall) in the table? Current query lists only selected user.

Important in table:
Datetime, sm, mm, conf
Areacode can be in both sm and mm but is counted uniqely
Fooled about with some subquerys / left join but how can i pass values to "mycall"?


SELECT COUNT(mycall), MAX(KJ_tid) FROM (SELECT t1.*, KJ_log.tid AS KJ_tid, KJ_log.sm AS KJ_sm, KJ_log.mm AS KJ_mm FROM (SELECT DISTINCT mycall, sm FROM KJ_log WHERE mycall = 'SM6TPJ' AND sm !='' AND conf = '1' UNION DISTINCT SELECT mycall, mm FROM KJ_log WHERE mycall = 'SM6TPJ' AND mm !='' AND conf = '1') AS t1 LEFT JOIN KJ_log ON (t1.sm = KJ_log.sm) OR (t1.sm = KJ_log.mm) where KJ_log.mycall = 'SM6TPJ' AND conf = '1' GROUP BY t1.sm) AS latestdate
SM6TOB 22-Apr-22 16:04pm View    
Never joke about SQL query ;-)
I try to explain a bit furter.

SM6ABC, 2022-04-01 09:00:00, AAAA, 1
SM6ABC, 2022-04-01 09:01:00, AAAB, 1
SM6ABC, 2022-04-01 09:12:00, AAAA, 1

SM6ABC occurs 3 times. I need to count distinct rows of "mm"-column (3:rd column in table). AAAA is the 1:st, AAAB is the 2:nd and for this row i need the date "2022-04-01 09:01:00" to be returned by the query. The 3:d row has AAAA again which is not unique. Hope you understand :-)
SM6TOB 22-Apr-22 1:39am View    
You reply "And...", I say and what???
Problem still remains!
Have a look at my output above. You will not get that with your MAX(tid) solution.
SM6TOB 21-Apr-22 15:25pm View    
tid corrected