• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to write a query ?

#1
Code:
My table look like
Slno    staffid    work    time_stamp
1    101    work1    1/11/2018
2    101    work1    2/11/2018
3    101    work2    2/11/2018
4    101    work1    3/11/2018
5    101    work2    3/11/2018
6    101    work3    3/11/2018
output should be displayed as
Code:
Date           Sesson    work    Amount
1/11/2018    FN    work1    300
2/11/2018    FN    work1    350
            AN    work2    
3/11/2018    FN    work1    350
            AN    work2    
            AN    work3
Code:
SELECT DATE_FORMAT(`time_stamp`,'%d-%m-%Y') as time_stamp,
 case when time(time_stamp) between '01:00:00' and '12:00:00' then 'FN'
      when time(time_stamp) between '12:00:00' and '24:00:00' then 'AN'
 end as period, work
from table1 order by time_stamp
I am struggled to write query. need suggestion


Attached Files Thumbnail(s)
   
Reply

#2
order by date
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
@kvanaraj,

Have you resolved this or are you still having an issue with it?
Reply

#4
(11-09-2018, 07:11 AM)php_rocs Wrote: @kvanaraj,

Have you resolved this or are you still having an issue with it?

I am not asking order by date, grouping of date with amount . just check attached image
Reply

#5
First, if your table field is called "wdate", why do you try to write a query that uses the field "time_stamp"?
Second, you need a value called "Amount" in your output. Where is it in your database?
Reply

#6
(11-14-2018, 12:08 PM)Wouter60 Wrote: First, if your table field is called "wdate", why do you try to write a query that uses the field "time_stamp"?
Second, you need a value called "Amount" in your output. Where is it in your database?
1,column name changed, 
2, the amount should calculated based on the count ( for  ex if count(an,fn)=1, amount 300,else 350)
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.