Jump to content

Sql Experts Urgent Help


Recommended Posts

Posted

corresht man...mLO5Za.gif

 

 

ee DB lo emaina trigger lantidi pettaava, sql meeda thread padagaane ala vachestav

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

  • loveindia

    24

  • nenu_devudni

    15

  • CheGuevara

    8

  • SUbba LIngam

    4

Top Posters In This Topic

Posted

devudu adi work avadu ga, what if you don't have meter for that record and it does have only tamper... it won't pickup the second priority item man.... mLO5Za.gif

  aa record ki ochina anadam lo chusukoledu  .. nu chepindi correst bhayya .. ipudu em cheyali   bye1

Posted

ee DB lo emaina trigger lantidi pettaava, sql meeda thread padagaane ala vachestav

 

I am admin mod noo man...mLO5Za.gif

Posted

  aa record ki ochina anadam lo chusukoledu  .. nu chepindi correst bhayya .. ipudu em cheyali   bye1

 

10 minutes wait chey man, tintunna, code raasi istaaa... mLO5Za.gif

Posted

10 minutes wait chey man, tintunna, code raasi istaaa... mLO5Za.gif thanks bhayya 

:)

Posted

Try this

Sorry edi try chey vastadi

Try this

Select * from
(

SELECT UWTSMEE_PREM_CODE,
UWTSMEE_MODEL,
UWTSMEE_ASVC_CODE,
UWTSMEE_ALERT_TIME,
UWTSMEE_ALERT_TYPE,
UWTSMEE_ALERT_MSG,
CASE WHEN UWTSMEE_ALERT_TYPE = 'METER REMOVAL' THEN 1
WHEN UWTSMEE_ALERT_TYPE = 'TAMPER ALERT' And UWTSMEE_ALERT_TYPE != 'METER REMOVAL' THEN 1
WHEN UWTSMEE_ALERT_TYPE = 'REVERSE ENERGY' and (UWTSMEE_ALERT_TYPE != 'METER REMOVAL' and UWTSMEE_ALERT_TYPE != 'TAMPER REMOVAL' )THEN 1
ELSE 0
END AS ALERT_TYPE
FROM UWTSMEE
WHERE UWTSMEE_WORK_IND IS NULL
AND UWTSMEE_PREM_CODE = '1018385')
Where alert_type = 1;

Might not be optimal one but give a try

Posted

Try this

sorry edi try chey vastadi

Try this

Select * from
(

SELECT UWTSMEE_PREM_CODE,
UWTSMEE_MODEL,
UWTSMEE_ASVC_CODE,
UWTSMEE_ALERT_TIME,
UWTSMEE_ALERT_TYPE,
UWTSMEE_ALERT_MSG,
CASE WHEN UWTSMEE_ALERT_TYPE = 'METER REMOVAL' THEN 1
WHEN UWTSMEE_ALERT_TYPE = 'TAMPER ALERT' And UWTSMEE_ALERT_TYPE != 'METER REMOVAL' THEN 1
WHEN UWTSMEE_ALERT_TYPE = 'REVERSE ENERGY' and (UWTSMEE_ALERT_TYPE != 'METER REMOVAL' and UWTSMEE_ALERT_TYPE != 'TAMPER REMOVAL' )THEN 1
ELSE 0
END AS ALERT_TYPE
FROM UWTSMEE
WHERE UWTSMEE_WORK_IND IS NULL
AND UWTSMEE_PREM_CODE = '1018385')
Where alert_type = 1;

Might not be optimal one but give a try

 

annitiki one vastundi kada man ila raastey, you are not considering each individual record kada...

Posted

DECLARE @Table TABLE
(minv_code INT,
alert_msg VARCHAR(10),
alert_time DATETIME
)
 
INSERT INTO @Table VALUES (873939,     'Reverse',          '7/24/2015 3:31:18'),
(873939,     'Tamper',           '7/24/2015 3:30:00')
,(873939,     'Meter',             '7/24/2015 3:31:22')
 
;WITH CTE AS
(
SELECT *
, CASE WHEN alert_msg = 'Meter' THEN 1
WHEN alert_msg = 'Tamper' THEN 2
WHEN alert_msg = 'Reverse' THEN 3 END AS id
FROM @table
)
, CTE2 AS (
 SELECT *, ROW_NUMBER() OVER (Partition by minv_code ORDER BY id) AS rnum
FROM CTE
)
SELECT minv_code, alert_msg, alert_time FROM CTE2
WHERE Rnum = 1
Posted

enjoy man,

 

next time when you can help some one please do help man.... idi nuvvu cheppina daani prakaram and naaku ardam aina daani prakaram raasanu man and this is lest cost query too so it will performance good.... mLO5Za.gif

Posted
DECLARE @Table TABLE
(minv_code INT,
alert_msg VARCHAR(10),
alert_time DATETIME
)
 
INSERT INTO @Table VALUES (873939,     'Reverse',          '7/24/2015 3:31:18'),
(873939,     'Tamper',           '7/24/2015 3:30:00')
,(873939,     'Meter',             '7/24/2015 3:31:22')
 
;WITH CTE AS
(
SELECT *
, CASE WHEN alert_msg = 'Meter' THEN 1
WHEN alert_msg = 'Tamper' THEN 2
WHEN alert_msg = 'Reverse' THEN 3 END AS id
FROM @table
)
, CTE2 AS (
 SELECT *, ROW_NUMBER() OVER (Partition by minv_code ORDER BY id) AS rnum
FROM CTE
)
SELECT minv_code, alert_msg, alert_time FROM CTE2
WHERE Rnum = 1

insert enduku bhayya .. that data is already in the table  bye1

Posted

insert enduku bhayya .. that data is already in the table  bye1

 

adi just sample data man, neeku ardam avadam kosam ala ichanu.... mLO5Za.gif

Posted

insert enduku bhayya .. that data is already in the table  bye1

 

ali2_0.gif?1290172604..nuvvu nijam gane devudivi bhayyo...  LoveIndia created a table and inserted data for get solution for you.. not that he is asking you to Insert.

×
×
  • Create New...